nix-store --optimise: Remove bogus statistics

This commit is contained in:
Eelco Dolstra 2014-05-15 11:33:46 +02:00
parent 690adeb03d
commit 84813af5b9
3 changed files with 9 additions and 14 deletions

View File

@ -34,14 +34,12 @@ struct Derivation;
struct OptimiseStats struct OptimiseStats
{ {
unsigned long totalFiles;
unsigned long sameContents;
unsigned long filesLinked; unsigned long filesLinked;
unsigned long long bytesFreed; unsigned long long bytesFreed;
unsigned long long blocksFreed; unsigned long long blocksFreed;
OptimiseStats() OptimiseStats()
{ {
totalFiles = sameContents = filesLinked = 0; filesLinked = 0;
bytesFreed = blocksFreed = 0; bytesFreed = blocksFreed = 0;
} }
}; };
@ -315,7 +313,7 @@ private:
#endif #endif
InodeHash loadInodeHash(); InodeHash loadInodeHash();
Strings readDirectoryIgnoringInodes(const Path & path, const InodeHash & inodeHash, OptimiseStats & stats); Strings readDirectoryIgnoringInodes(const Path & path, const InodeHash & inodeHash);
void optimisePath_(OptimiseStats & stats, const Path & path, InodeHash & inodeHash); void optimisePath_(OptimiseStats & stats, const Path & path, InodeHash & inodeHash);
// Internal versions that are not wrapped in retry_sqlite. // Internal versions that are not wrapped in retry_sqlite.

View File

@ -39,6 +39,7 @@ struct MakeReadOnly
} }
}; };
LocalStore::InodeHash LocalStore::loadInodeHash() LocalStore::InodeHash LocalStore::loadInodeHash()
{ {
printMsg(lvlDebug, "loading hash inodes in memory"); printMsg(lvlDebug, "loading hash inodes in memory");
@ -60,7 +61,8 @@ LocalStore::InodeHash LocalStore::loadInodeHash()
return inodeHash; return inodeHash;
} }
Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHash & inodeHash, OptimiseStats & stats)
Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHash & inodeHash)
{ {
Strings names; Strings names;
@ -73,7 +75,6 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHa
if (inodeHash.count(dirent->d_ino)) { if (inodeHash.count(dirent->d_ino)) {
printMsg(lvlDebug, format("`%1%' is already linked") % dirent->d_name); printMsg(lvlDebug, format("`%1%' is already linked") % dirent->d_name);
stats.totalFiles++;
continue; continue;
} }
@ -86,6 +87,7 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHa
return names; return names;
} }
void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHash & inodeHash) void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHash & inodeHash)
{ {
checkInterrupt(); checkInterrupt();
@ -95,7 +97,7 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
throw SysError(format("getting attributes of path `%1%'") % path); throw SysError(format("getting attributes of path `%1%'") % path);
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
Strings names = readDirectoryIgnoringInodes(path, inodeHash, stats); Strings names = readDirectoryIgnoringInodes(path, inodeHash);
foreach (Strings::iterator, i, names) foreach (Strings::iterator, i, names)
optimisePath_(stats, path + "/" + *i, inodeHash); optimisePath_(stats, path + "/" + *i, inodeHash);
return; return;
@ -117,8 +119,6 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
return; return;
} }
stats.totalFiles++;
/* This can still happen on top-level files */ /* This can still happen on top-level files */
if (st.st_nlink > 1 && inodeHash.count(st.st_ino)) { if (st.st_nlink > 1 && inodeHash.count(st.st_ino)) {
printMsg(lvlDebug, format("`%1%' is already linked, with %2% other file(s).") % path % (st.st_nlink - 2)); printMsg(lvlDebug, format("`%1%' is already linked, with %2% other file(s).") % path % (st.st_nlink - 2));
@ -158,7 +158,6 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
if (lstat(linkPath.c_str(), &stLink)) if (lstat(linkPath.c_str(), &stLink))
throw SysError(format("getting attributes of path `%1%'") % linkPath); throw SysError(format("getting attributes of path `%1%'") % linkPath);
stats.sameContents++;
if (st.st_ino == stLink.st_ino) { if (st.st_ino == stLink.st_ino) {
printMsg(lvlDebug, format("`%1%' is already linked to `%2%'") % path % linkPath); printMsg(lvlDebug, format("`%1%' is already linked to `%2%'") % path % linkPath);
return; return;

View File

@ -801,11 +801,9 @@ static void opRepairPath(Strings opFlags, Strings opArgs)
static void showOptimiseStats(OptimiseStats & stats) static void showOptimiseStats(OptimiseStats & stats)
{ {
printMsg(lvlError, printMsg(lvlError,
format("%1% freed by hard-linking %2% files; there are %3% files with equal contents out of %4% files in total") format("%1% freed by hard-linking %2% files")
% showBytes(stats.bytesFreed) % showBytes(stats.bytesFreed)
% stats.filesLinked % stats.filesLinked);
% stats.sameContents
% stats.totalFiles);
} }