mirror of
https://github.com/NixOS/nix.git
synced 2025-12-08 18:11:02 +01:00
Merge pull request #14705 from NixOS/pathinfo-cache-string-to-store-path
libstore: Make Store::pathInfoCache use StorePath instead of std::string
This commit is contained in:
commit
676fb0fffc
4 changed files with 10 additions and 12 deletions
|
|
@ -127,8 +127,7 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
|
|||
|
||||
upsertFile(narInfoFile, narInfo->to_string(*this), "text/x-nix-narinfo");
|
||||
|
||||
pathInfoCache->lock()->upsert(
|
||||
std::string(narInfo->path.to_string()), PathInfoCacheValue{.value = std::shared_ptr<NarInfo>(narInfo)});
|
||||
pathInfoCache->lock()->upsert(narInfo->path, PathInfoCacheValue{.value = std::shared_ptr<NarInfo>(narInfo)});
|
||||
|
||||
if (diskCache)
|
||||
diskCache->upsertNarInfo(
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ protected:
|
|||
|
||||
// Note: this is a `ref` to avoid false sharing with immutable
|
||||
// bits of `Store`.
|
||||
ref<SharedSync<LRUCache<std::string, PathInfoCacheValue>>> pathInfoCache;
|
||||
ref<SharedSync<LRUCache<StorePath, PathInfoCacheValue>>> pathInfoCache;
|
||||
|
||||
std::shared_ptr<NarInfoDiskCache> diskCache;
|
||||
|
||||
|
|
|
|||
|
|
@ -722,8 +722,7 @@ uint64_t LocalStore::addValidPath(State & state, const ValidPathInfo & info, boo
|
|||
}
|
||||
}
|
||||
|
||||
pathInfoCache->lock()->upsert(
|
||||
std::string(info.path.to_string()), PathInfoCacheValue{.value = std::make_shared<const ValidPathInfo>(info)});
|
||||
pathInfoCache->lock()->upsert(info.path, PathInfoCacheValue{.value = std::make_shared<const ValidPathInfo>(info)});
|
||||
|
||||
return id;
|
||||
}
|
||||
|
|
@ -1021,7 +1020,7 @@ void LocalStore::invalidatePath(State & state, const StorePath & path)
|
|||
/* Note that the foreign key constraints on the Refs table take
|
||||
care of deleting the references entries for `path'. */
|
||||
|
||||
pathInfoCache->lock()->erase(std::string(path.to_string()));
|
||||
pathInfoCache->lock()->erase(path);
|
||||
}
|
||||
|
||||
const PublicKeys & LocalStore::getPublicKeys()
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ bool Store::PathInfoCacheValue::isKnownNow()
|
|||
|
||||
void Store::invalidatePathInfoCacheFor(const StorePath & path)
|
||||
{
|
||||
pathInfoCache->lock()->erase(path.to_string());
|
||||
pathInfoCache->lock()->erase(path);
|
||||
}
|
||||
|
||||
std::map<std::string, std::optional<StorePath>> Store::queryStaticPartialDerivationOutputMap(const StorePath & path)
|
||||
|
|
@ -471,7 +471,7 @@ void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, Substituta
|
|||
|
||||
bool Store::isValidPath(const StorePath & storePath)
|
||||
{
|
||||
auto res = pathInfoCache->lock()->get(storePath.to_string());
|
||||
auto res = pathInfoCache->lock()->get(storePath);
|
||||
if (res && res->isKnownNow()) {
|
||||
stats.narInfoReadAverted++;
|
||||
return res->didExist();
|
||||
|
|
@ -483,7 +483,7 @@ bool Store::isValidPath(const StorePath & storePath)
|
|||
if (res.first != NarInfoDiskCache::oUnknown) {
|
||||
stats.narInfoReadAverted++;
|
||||
pathInfoCache->lock()->upsert(
|
||||
storePath.to_string(),
|
||||
storePath,
|
||||
res.first == NarInfoDiskCache::oInvalid ? PathInfoCacheValue{}
|
||||
: PathInfoCacheValue{.value = res.second});
|
||||
return res.first == NarInfoDiskCache::oValid;
|
||||
|
|
@ -537,7 +537,7 @@ std::optional<std::shared_ptr<const ValidPathInfo>> Store::queryPathInfoFromClie
|
|||
{
|
||||
auto hashPart = std::string(storePath.hashPart());
|
||||
|
||||
auto res = pathInfoCache->lock()->get(storePath.to_string());
|
||||
auto res = pathInfoCache->lock()->get(storePath);
|
||||
if (res && res->isKnownNow()) {
|
||||
stats.narInfoReadAverted++;
|
||||
if (res->didExist())
|
||||
|
|
@ -551,7 +551,7 @@ std::optional<std::shared_ptr<const ValidPathInfo>> Store::queryPathInfoFromClie
|
|||
if (res.first != NarInfoDiskCache::oUnknown) {
|
||||
stats.narInfoReadAverted++;
|
||||
pathInfoCache->lock()->upsert(
|
||||
storePath.to_string(),
|
||||
storePath,
|
||||
res.first == NarInfoDiskCache::oInvalid ? PathInfoCacheValue{}
|
||||
: PathInfoCacheValue{.value = res.second});
|
||||
if (res.first == NarInfoDiskCache::oInvalid || !goodStorePath(storePath, res.second->path))
|
||||
|
|
@ -591,7 +591,7 @@ void Store::queryPathInfo(const StorePath & storePath, Callback<ref<const ValidP
|
|||
if (diskCache)
|
||||
diskCache->upsertNarInfo(config.getReference().render(/*FIXME withParams=*/false), hashPart, info);
|
||||
|
||||
pathInfoCache->lock()->upsert(storePath.to_string(), PathInfoCacheValue{.value = info});
|
||||
pathInfoCache->lock()->upsert(storePath, PathInfoCacheValue{.value = info});
|
||||
|
||||
if (!info || !goodStorePath(storePath, info->path)) {
|
||||
stats.narInfoMissing++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue