forked from lix-project/hydra
S3BinaryCacheStore: Use disk cache
This commit is contained in:
parent
b2b978eda0
commit
b50a105ca7
|
@ -21,8 +21,8 @@ BuildOutput getBuildOutput(nix::ref<Store> store,
|
||||||
store->computeFSClosure(output, closure);
|
store->computeFSClosure(output, closure);
|
||||||
for (auto & path : closure) {
|
for (auto & path : closure) {
|
||||||
auto info = store->queryPathInfo(path);
|
auto info = store->queryPathInfo(path);
|
||||||
res.closureSize += info.narSize;
|
res.closureSize += info->narSize;
|
||||||
if (outputs.find(path) != outputs.end()) res.size += info.narSize;
|
if (outputs.find(path) != outputs.end()) res.size += info->narSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get build products. */
|
/* Get build products. */
|
||||||
|
|
|
@ -630,9 +630,8 @@ void State::dumpStatus(Connection & conn, bool log)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto store = dynamic_cast<S3BinaryCacheStore *>(&*getDestStore());
|
auto store = getDestStore();
|
||||||
|
|
||||||
if (store) {
|
|
||||||
root.attr("store");
|
root.attr("store");
|
||||||
JSONObject nested(out);
|
JSONObject nested(out);
|
||||||
|
|
||||||
|
@ -641,7 +640,7 @@ void State::dumpStatus(Connection & conn, bool log)
|
||||||
nested.attr("narInfoReadAverted", stats.narInfoReadAverted);
|
nested.attr("narInfoReadAverted", stats.narInfoReadAverted);
|
||||||
nested.attr("narInfoMissing", stats.narInfoMissing);
|
nested.attr("narInfoMissing", stats.narInfoMissing);
|
||||||
nested.attr("narInfoWrite", stats.narInfoWrite);
|
nested.attr("narInfoWrite", stats.narInfoWrite);
|
||||||
nested.attr("narInfoCacheSize", stats.narInfoCacheSize);
|
nested.attr("narInfoCacheSize", stats.pathInfoCacheSize);
|
||||||
nested.attr("narRead", stats.narRead);
|
nested.attr("narRead", stats.narRead);
|
||||||
nested.attr("narReadBytes", stats.narReadBytes);
|
nested.attr("narReadBytes", stats.narReadBytes);
|
||||||
nested.attr("narReadCompressedBytes", stats.narReadCompressedBytes);
|
nested.attr("narReadCompressedBytes", stats.narReadCompressedBytes);
|
||||||
|
@ -685,7 +684,6 @@ void State::dumpStatus(Connection & conn, bool log)
|
||||||
+ s3Stats.getBytes / (1024.0 * 1024.0 * 1024.0) * 0.09);
|
+ s3Stats.getBytes / (1024.0 * 1024.0 * 1024.0) * 0.09);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (log && time(0) >= lastStatusLogged + statusLogInterval) {
|
if (log && time(0) >= lastStatusLogged + statusLogInterval) {
|
||||||
printMsg(lvlInfo, format("status: %1%") % out.str());
|
printMsg(lvlInfo, format("status: %1%") % out.str());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "s3-binary-cache-store.hh"
|
#include "s3-binary-cache-store.hh"
|
||||||
|
|
||||||
#include "nar-info.hh"
|
#include "nar-info.hh"
|
||||||
|
#include "nar-info-disk-cache.hh"
|
||||||
|
|
||||||
#include <aws/core/client/ClientConfiguration.h>
|
#include <aws/core/client/ClientConfiguration.h>
|
||||||
#include <aws/s3/S3Client.h>
|
#include <aws/s3/S3Client.h>
|
||||||
|
@ -38,6 +39,12 @@ S3BinaryCacheStore::S3BinaryCacheStore(std::shared_ptr<Store> localStore,
|
||||||
, config(makeConfig())
|
, config(makeConfig())
|
||||||
, client(make_ref<Aws::S3::S3Client>(*config))
|
, client(make_ref<Aws::S3::S3Client>(*config))
|
||||||
{
|
{
|
||||||
|
diskCache = getNarInfoDiskCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string S3BinaryCacheStore::getUri()
|
||||||
|
{
|
||||||
|
return "s3://" + bucketName;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<Aws::Client::ClientConfiguration> S3BinaryCacheStore::makeConfig()
|
ref<Aws::Client::ClientConfiguration> S3BinaryCacheStore::makeConfig()
|
||||||
|
@ -50,6 +57,8 @@ ref<Aws::Client::ClientConfiguration> S3BinaryCacheStore::makeConfig()
|
||||||
|
|
||||||
void S3BinaryCacheStore::init()
|
void S3BinaryCacheStore::init()
|
||||||
{
|
{
|
||||||
|
if (!diskCache->cacheExists(getUri())) {
|
||||||
|
|
||||||
/* Create the bucket if it doesn't already exists. */
|
/* Create the bucket if it doesn't already exists. */
|
||||||
// FIXME: HeadBucket would be more appropriate, but doesn't return
|
// FIXME: HeadBucket would be more appropriate, but doesn't return
|
||||||
// an easily parsed 404 message.
|
// an easily parsed 404 message.
|
||||||
|
@ -70,6 +79,9 @@ void S3BinaryCacheStore::init()
|
||||||
Aws::S3::Model::BucketLocationConstraint::US) */ )));
|
Aws::S3::Model::BucketLocationConstraint::US) */ )));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diskCache->createCache(getUri());
|
||||||
|
}
|
||||||
|
|
||||||
BinaryCacheStore::init();
|
BinaryCacheStore::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,10 +94,10 @@ const S3BinaryCacheStore::Stats & S3BinaryCacheStore::getS3Stats()
|
||||||
fetches the .narinfo file, rather than first checking for its
|
fetches the .narinfo file, rather than first checking for its
|
||||||
existence via a HEAD request. Since .narinfos are small, doing a
|
existence via a HEAD request. Since .narinfos are small, doing a
|
||||||
GET is unlikely to be slower than HEAD. */
|
GET is unlikely to be slower than HEAD. */
|
||||||
bool S3BinaryCacheStore::isValidPath(const Path & storePath)
|
bool S3BinaryCacheStore::isValidPathUncached(const Path & storePath)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
readNarInfo(storePath);
|
queryPathInfo(storePath);
|
||||||
return true;
|
return true;
|
||||||
} catch (InvalidPath & e) {
|
} catch (InvalidPath & e) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
|
|
||||||
|
std::string getUri();
|
||||||
|
|
||||||
struct Stats
|
struct Stats
|
||||||
{
|
{
|
||||||
std::atomic<uint64_t> put{0};
|
std::atomic<uint64_t> put{0};
|
||||||
|
@ -38,7 +40,7 @@ public:
|
||||||
|
|
||||||
const Stats & getS3Stats();
|
const Stats & getS3Stats();
|
||||||
|
|
||||||
bool isValidPath(const Path & storePath) override;
|
bool isValidPathUncached(const Path & storePath) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue