mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 22:46:16 +02:00
2df9cbeb47
E.g. $ time nix cat-store --store https://cache.nixos.org?local-nar-cache=/tmp/nars \ /nix/store/b0w2hafndl09h64fhb86kw6bmhbmnpm1-blender-2.79/share/icons/hicolor/scalable/apps/blender.svg > /dev/null real 0m4.139s $ time nix cat-store --store https://cache.nixos.org?local-nar-cache=/tmp/nars \ /nix/store/b0w2hafndl09h64fhb86kw6bmhbmnpm1-blender-2.79/share/icons/hicolor/scalable/apps/blender.svg > /dev/null real 0m0.024s (Before, the second call took ~0.220s.) This will use a NAR listing in /tmp/nars/b0w2hafndl09h64fhb86kw6bmhbmnpm1.ls containing all metadata, including the offsets of regular files inside the NAR. Thus, we don't need to read the entire NAR. (We do read the entire listing, but that's generally pretty small. We could use a SQLite DB by borrowing some more code from nixos-channel-scripts/file-cache.hh.) This is primarily useful when Hydra is serving files from an S3 binary cache, in particular when you have giant NARs. E.g. we had some 12 GiB NARs, so accessing individuals files was pretty slow.
40 lines
848 B
C++
40 lines
848 B
C++
#pragma once
|
|
|
|
#include "fs-accessor.hh"
|
|
#include "ref.hh"
|
|
#include "store-api.hh"
|
|
|
|
namespace nix {
|
|
|
|
class RemoteFSAccessor : public FSAccessor
|
|
{
|
|
ref<Store> store;
|
|
|
|
std::map<Path, ref<FSAccessor>> nars;
|
|
|
|
Path cacheDir;
|
|
|
|
std::pair<ref<FSAccessor>, Path> fetch(const Path & path_);
|
|
|
|
friend class BinaryCacheStore;
|
|
|
|
Path makeCacheFile(const Path & storePath, const std::string & ext);
|
|
|
|
void addToCache(const Path & storePath, const std::string & nar,
|
|
ref<FSAccessor> narAccessor);
|
|
|
|
public:
|
|
|
|
RemoteFSAccessor(ref<Store> store,
|
|
const /* FIXME: use std::optional */ Path & cacheDir = "");
|
|
|
|
Stat stat(const Path & path) override;
|
|
|
|
StringSet readDirectory(const Path & path) override;
|
|
|
|
std::string readFile(const Path & path) override;
|
|
|
|
std::string readLink(const Path & path) override;
|
|
};
|
|
|
|
}
|