forked from lix-project/hydra
Updates for negative .narinfo caching
This commit is contained in:
parent
177bf25d64
commit
afb86638cd
|
@ -639,6 +639,7 @@ void State::dumpStatus(Connection & conn, bool log)
|
||||||
auto & stats = store->getStats();
|
auto & stats = store->getStats();
|
||||||
nested.attr("narInfoRead", stats.narInfoRead);
|
nested.attr("narInfoRead", stats.narInfoRead);
|
||||||
nested.attr("narInfoReadAverted", stats.narInfoReadAverted);
|
nested.attr("narInfoReadAverted", stats.narInfoReadAverted);
|
||||||
|
nested.attr("narInfoMissing", stats.narInfoMissing);
|
||||||
nested.attr("narInfoWrite", stats.narInfoWrite);
|
nested.attr("narInfoWrite", stats.narInfoWrite);
|
||||||
nested.attr("narInfoCacheSize", stats.narInfoCacheSize);
|
nested.attr("narInfoCacheSize", stats.narInfoCacheSize);
|
||||||
nested.attr("narRead", stats.narRead);
|
nested.attr("narRead", stats.narRead);
|
||||||
|
|
|
@ -87,9 +87,8 @@ bool S3BinaryCacheStore::isValidPath(const Path & storePath)
|
||||||
try {
|
try {
|
||||||
readNarInfo(storePath);
|
readNarInfo(storePath);
|
||||||
return true;
|
return true;
|
||||||
} catch (S3Error & e) {
|
} catch (InvalidPath & e) {
|
||||||
if (e.err == Aws::S3::S3Errors::NO_SUCH_KEY) return false;
|
return false;
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ void S3BinaryCacheStore::upsertFile(const std::string & path, const std::string
|
||||||
stats.putTimeMs += duration;
|
stats.putTimeMs += duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string S3BinaryCacheStore::getFile(const std::string & path)
|
std::shared_ptr<std::string> S3BinaryCacheStore::getFile(const std::string & path)
|
||||||
{
|
{
|
||||||
printMsg(lvlDebug, format("fetching ‘s3://%1%/%2%’...") % bucketName % path);
|
printMsg(lvlDebug, format("fetching ‘s3://%1%/%2%’...") % bucketName % path);
|
||||||
|
|
||||||
|
@ -157,24 +156,31 @@ std::string S3BinaryCacheStore::getFile(const std::string & path)
|
||||||
|
|
||||||
stats.get++;
|
stats.get++;
|
||||||
|
|
||||||
auto now1 = std::chrono::steady_clock::now();
|
try {
|
||||||
|
|
||||||
auto result = checkAws(format("AWS error fetching ‘%s’") % path,
|
auto now1 = std::chrono::steady_clock::now();
|
||||||
client->GetObject(request));
|
|
||||||
|
|
||||||
auto now2 = std::chrono::steady_clock::now();
|
auto result = checkAws(format("AWS error fetching ‘%s’") % path,
|
||||||
|
client->GetObject(request));
|
||||||
|
|
||||||
auto res = dynamic_cast<std::stringstream &>(result.GetBody()).str();
|
auto now2 = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
|
auto res = dynamic_cast<std::stringstream &>(result.GetBody()).str();
|
||||||
|
|
||||||
printMsg(lvlTalkative, format("downloaded ‘s3://%1%/%2%’ (%3% bytes) in %4% ms")
|
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
|
||||||
% bucketName % path % res.size() % duration);
|
|
||||||
|
|
||||||
stats.getBytes += res.size();
|
printMsg(lvlTalkative, format("downloaded ‘s3://%1%/%2%’ (%3% bytes) in %4% ms")
|
||||||
stats.getTimeMs += duration;
|
% bucketName % path % res.size() % duration);
|
||||||
|
|
||||||
return res;
|
stats.getBytes += res.size();
|
||||||
|
stats.getTimeMs += duration;
|
||||||
|
|
||||||
|
return std::make_shared<std::string>(res);
|
||||||
|
|
||||||
|
} catch (S3Error & e) {
|
||||||
|
if (e.err == Aws::S3::S3Errors::NO_SUCH_KEY) return 0;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ protected:
|
||||||
|
|
||||||
void upsertFile(const std::string & path, const std::string & data) override;
|
void upsertFile(const std::string & path, const std::string & data) override;
|
||||||
|
|
||||||
std::string getFile(const std::string & path) override;
|
std::shared_ptr<std::string> getFile(const std::string & path) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue