Skip to content

Commit

Permalink
Remove the drv resolution caching mechanism
Browse files Browse the repository at this point in the history
It isn't needed anymore now that don't need to eagerly resolve
everything like we used to do. So we can safely get rid of it
  • Loading branch information
thufschmitt committed Feb 16, 2021
1 parent 413ecb7 commit da404b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
34 changes: 1 addition & 33 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ static void rewriteDerivation(Store & store, BasicDerivation & drv, const String

}

std::optional<BasicDerivation> Derivation::tryResolveUncached(Store & store) {
std::optional<BasicDerivation> Derivation::tryResolve(Store & store) {
BasicDerivation resolved { *this };

// Input paths that we'll want to rewrite in the derivation
Expand Down Expand Up @@ -776,36 +776,4 @@ std::optional<BasicDerivation> Derivation::tryResolveUncached(Store & store) {
return resolved;
}

std::optional<BasicDerivation> Derivation::tryResolve(Store& store)
{
auto drvPath = writeDerivation(store, *this, NoRepair, false);
return Derivation::tryResolve(store, drvPath);
}

std::optional<BasicDerivation> Derivation::tryResolve(Store& store, const StorePath& drvPath)
{
// This is quite dirty and leaky, but will disappear once #4340 is merged
static Sync<std::map<StorePath, std::optional<Derivation>>> resolutionsCache;

debug("trying to resolve %s", store.printStorePath(drvPath));

{
auto resolutions = resolutionsCache.lock();
auto resolvedDrvIter = resolutions->find(drvPath);
if (resolvedDrvIter != resolutions->end()) {
auto & [_, resolvedDrv] = *resolvedDrvIter;
return *resolvedDrv;
}
}

/* Try resolve drv and use that path instead. */
auto drv = store.readDerivation(drvPath);
auto attempt = drv.tryResolveUncached(store);
if (!attempt)
return std::nullopt;
/* Store in memo table. */
resolutionsCache.lock()->insert_or_assign(drvPath, *attempt);
return *attempt;
}

}
4 changes: 0 additions & 4 deletions src/libstore/derivations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,10 @@ struct Derivation : BasicDerivation
2. Input placeholders are replaced with realized input store paths. */
std::optional<BasicDerivation> tryResolve(Store & store);
static std::optional<BasicDerivation> tryResolve(Store & store, const StorePath & drvPath);

Derivation() = default;
Derivation(const BasicDerivation & bd) : BasicDerivation(bd) { }
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }

private:
std::optional<BasicDerivation> tryResolveUncached(Store & store);
};


Expand Down

0 comments on commit da404b5

Please sign in to comment.