mirror of
https://github.com/NixOS/nix.git
synced 2025-04-16 06:08:03 +00:00
Add some stats for the evaluation caching
This commit is contained in:
parent
007c4a7f3a
commit
357e095a7b
@ -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");
|
||||
|
@ -342,6 +342,8 @@ public:
|
||||
|
||||
void realiseContext(const PathSet & context);
|
||||
|
||||
void updateCacheStats(ValueCache::CacheResult);
|
||||
|
||||
private:
|
||||
|
||||
unsigned long nrEnvs = 0;
|
||||
@ -355,6 +357,10 @@ private:
|
||||
unsigned long nrListConcats = 0;
|
||||
unsigned long nrPrimOpCalls = 0;
|
||||
unsigned long nrFunctionCalls = 0;
|
||||
unsigned long nrCacheHits = 0;
|
||||
unsigned long nrCacheMisses = 0;
|
||||
unsigned long nrUncacheable = 0;
|
||||
unsigned long nrUncached = 0;
|
||||
|
||||
bool countCalls;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user