mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 17:29:36 +01:00
Add some stats for the evaluation caching
This commit is contained in:
parent
007c4a7f3a
commit
357e095a7b
2 changed files with 36 additions and 0 deletions
|
|
@ -1257,6 +1257,27 @@ ValueCache::CacheResult ValueCache::getValue(Store & store, const std::vector<Sy
|
|||
cachedValue);
|
||||
}
|
||||
|
||||
void EvalState::updateCacheStats(ValueCache::CacheResult cacheResult)
|
||||
{
|
||||
switch (cacheResult.returnCode) {
|
||||
case ValueCache::CacheHit:
|
||||
nrCacheHits++;
|
||||
break;
|
||||
case ValueCache::CacheMiss:
|
||||
nrCacheMisses++;
|
||||
break;
|
||||
case ValueCache::UnCacheable:
|
||||
nrUncacheable++;
|
||||
break;
|
||||
case ValueCache::NoCacheKey:
|
||||
nrUncached++;
|
||||
break;
|
||||
case ValueCache::Forward:
|
||||
nrCacheHits++;
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
struct ExprCastedVar : Expr
|
||||
{
|
||||
Value * v;
|
||||
|
|
@ -1280,6 +1301,7 @@ EvalState::AttrAccesResult EvalState::lazyGetOptionalAttrField(Value & attrs, co
|
|||
Value * dest = allocValue();
|
||||
auto evalCache = attrs.getCache();
|
||||
auto cacheResult = evalCache.getValue(*store, selector, *dest);
|
||||
updateCacheStats(cacheResult);
|
||||
|
||||
if (cacheResult.returnCode == ValueCache::CacheHit) {
|
||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||
|
|
@ -1324,6 +1346,7 @@ EvalState::AttrAccesResult EvalState::getOptionalAttrField(Value & attrs, const
|
|||
};
|
||||
|
||||
auto cacheResult = evalCache.getValue(*store, selector, dest);
|
||||
updateCacheStats(cacheResult);
|
||||
|
||||
if (cacheResult.returnCode == ValueCache::CacheHit) {
|
||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||
|
|
@ -2306,6 +2329,13 @@ void EvalState::printStats()
|
|||
topObj.attr("nrLookups", nrLookups);
|
||||
topObj.attr("nrPrimOpCalls", nrPrimOpCalls);
|
||||
topObj.attr("nrFunctionCalls", nrFunctionCalls);
|
||||
{
|
||||
auto cache = topObj.object("evalCache");
|
||||
cache.attr("nrCacheMisses", nrCacheMisses);
|
||||
cache.attr("nrCacheHits", nrCacheHits);
|
||||
cache.attr("nrUncached", nrUncached);
|
||||
cache.attr("nrUncacheable", nrUncacheable);
|
||||
}
|
||||
#if HAVE_BOEHMGC
|
||||
{
|
||||
auto gc = topObj.object("gc");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue