Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/include/nix/store/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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())
Expand All @@ -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))
Expand Down Expand Up @@ -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++;
Expand Down
Loading