Add an 'optimiseStore' remote procedure call.
This commit is contained in:
parent
3bb89c3a31
commit
6621195e48
|
@ -167,6 +167,9 @@ public:
|
||||||
files with the same contents. */
|
files with the same contents. */
|
||||||
void optimiseStore(OptimiseStats & stats);
|
void optimiseStore(OptimiseStats & stats);
|
||||||
|
|
||||||
|
/* Generic variant of the above method. */
|
||||||
|
void optimiseStore();
|
||||||
|
|
||||||
/* Optimise a single store path. */
|
/* Optimise a single store path. */
|
||||||
void optimisePath(const Path & path);
|
void optimisePath(const Path & path);
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,22 @@ void LocalStore::optimiseStore(OptimiseStats & stats)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string showBytes(unsigned long long bytes)
|
||||||
|
{
|
||||||
|
return (format("%.2f MiB") % (bytes / (1024.0 * 1024.0))).str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalStore::optimiseStore()
|
||||||
|
{
|
||||||
|
OptimiseStats stats;
|
||||||
|
|
||||||
|
optimiseStore(stats);
|
||||||
|
|
||||||
|
printMsg(lvlError,
|
||||||
|
format("%1% freed by hard-linking %2% files")
|
||||||
|
% showBytes(stats.bytesFreed)
|
||||||
|
% stats.filesLinked);
|
||||||
|
}
|
||||||
|
|
||||||
void LocalStore::optimisePath(const Path & path)
|
void LocalStore::optimisePath(const Path & path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -577,6 +577,13 @@ void RemoteStore::clearFailedPaths(const PathSet & paths)
|
||||||
readInt(from);
|
readInt(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoteStore::optimiseStore()
|
||||||
|
{
|
||||||
|
openConnection();
|
||||||
|
writeInt(wopOptimiseStore, to);
|
||||||
|
processStderr();
|
||||||
|
readInt(from);
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteStore::processStderr(Sink * sink, Source * source)
|
void RemoteStore::processStderr(Sink * sink, Source * source)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,9 @@ public:
|
||||||
PathSet queryFailedPaths();
|
PathSet queryFailedPaths();
|
||||||
|
|
||||||
void clearFailedPaths(const PathSet & paths);
|
void clearFailedPaths(const PathSet & paths);
|
||||||
|
|
||||||
|
void optimiseStore();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AutoCloseFD fdSocket;
|
AutoCloseFD fdSocket;
|
||||||
FdSink to;
|
FdSink to;
|
||||||
|
|
|
@ -250,6 +250,10 @@ public:
|
||||||
`nix-store --register-validity'. */
|
`nix-store --register-validity'. */
|
||||||
string makeValidityRegistration(const PathSet & paths,
|
string makeValidityRegistration(const PathSet & paths,
|
||||||
bool showDerivers, bool showHash);
|
bool showDerivers, bool showHash);
|
||||||
|
|
||||||
|
/* Optimise the disk space usage of the Nix store by hard-linking files
|
||||||
|
with the same contents. */
|
||||||
|
virtual void optimiseStore() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ typedef enum {
|
||||||
wopQueryValidPaths = 31,
|
wopQueryValidPaths = 31,
|
||||||
wopQuerySubstitutablePaths = 32,
|
wopQuerySubstitutablePaths = 32,
|
||||||
wopQueryValidDerivers = 33,
|
wopQueryValidDerivers = 33,
|
||||||
|
wopOptimiseStore = 34
|
||||||
} WorkerOp;
|
} WorkerOp;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -640,6 +640,13 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case wopOptimiseStore:
|
||||||
|
startWork();
|
||||||
|
store->optimiseStore();
|
||||||
|
stopWork();
|
||||||
|
writeInt(1, to);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw Error(format("invalid operation %1%") % op);
|
throw Error(format("invalid operation %1%") % op);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue