mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
Add some stats for the evaluation caching
This commit is contained in:
parent
8d95e1f299
commit
7c718646cb
2 changed files with 36 additions and 0 deletions
|
|
@ -1163,6 +1163,28 @@ std::pair<ValueCache::CacheResult, ValueCache> ValueCache::getValue(EvalState &
|
||||||
return { cacheResult, ValueCache(resultingCursor) };
|
return { cacheResult, ValueCache(resultingCursor) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EvalState::getAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos, Value & dest)
|
bool EvalState::getAttrField(Value & attrs, const std::vector<Symbol> & selector, const Pos & pos, Value & dest)
|
||||||
{
|
{
|
||||||
Pos * pos2 = 0;
|
Pos * pos2 = 0;
|
||||||
|
|
@ -1171,6 +1193,7 @@ bool EvalState::getAttrField(Value & attrs, const std::vector<Symbol> & selector
|
||||||
if (attrs.type() == nAttrs) {
|
if (attrs.type() == nAttrs) {
|
||||||
auto eval_cache = attrs.attrs->eval_cache;
|
auto eval_cache = attrs.attrs->eval_cache;
|
||||||
auto [ cacheResult, resultingCursor ] = eval_cache.getValue(*this, selector, dest);
|
auto [ cacheResult, resultingCursor ] = eval_cache.getValue(*this, selector, dest);
|
||||||
|
updateCacheStats(cacheResult);
|
||||||
switch (cacheResult.returnCode) {
|
switch (cacheResult.returnCode) {
|
||||||
case ValueCache::CacheHit:
|
case ValueCache::CacheHit:
|
||||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||||
|
|
@ -2063,6 +2086,13 @@ void EvalState::printStats()
|
||||||
topObj.attr("nrLookups", nrLookups);
|
topObj.attr("nrLookups", nrLookups);
|
||||||
topObj.attr("nrPrimOpCalls", nrPrimOpCalls);
|
topObj.attr("nrPrimOpCalls", nrPrimOpCalls);
|
||||||
topObj.attr("nrFunctionCalls", nrFunctionCalls);
|
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
|
#if HAVE_BOEHMGC
|
||||||
{
|
{
|
||||||
auto gc = topObj.object("gc");
|
auto gc = topObj.object("gc");
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,8 @@ public:
|
||||||
|
|
||||||
void realiseContext(const PathSet & context);
|
void realiseContext(const PathSet & context);
|
||||||
|
|
||||||
|
void updateCacheStats(ValueCache::CacheResult);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned long nrEnvs = 0;
|
unsigned long nrEnvs = 0;
|
||||||
|
|
@ -327,6 +329,10 @@ private:
|
||||||
unsigned long nrListConcats = 0;
|
unsigned long nrListConcats = 0;
|
||||||
unsigned long nrPrimOpCalls = 0;
|
unsigned long nrPrimOpCalls = 0;
|
||||||
unsigned long nrFunctionCalls = 0;
|
unsigned long nrFunctionCalls = 0;
|
||||||
|
unsigned long nrCacheHits = 0;
|
||||||
|
unsigned long nrCacheMisses = 0;
|
||||||
|
unsigned long nrUncacheable = 0;
|
||||||
|
unsigned long nrUncached = 0;
|
||||||
|
|
||||||
bool countCalls;
|
bool countCalls;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue