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);
|
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
|
struct ExprCastedVar : Expr
|
||||||
{
|
{
|
||||||
Value * v;
|
Value * v;
|
||||||
|
|
@ -1280,6 +1301,7 @@ EvalState::AttrAccesResult EvalState::lazyGetOptionalAttrField(Value & attrs, co
|
||||||
Value * dest = allocValue();
|
Value * dest = allocValue();
|
||||||
auto evalCache = attrs.getCache();
|
auto evalCache = attrs.getCache();
|
||||||
auto cacheResult = evalCache.getValue(*store, selector, *dest);
|
auto cacheResult = evalCache.getValue(*store, selector, *dest);
|
||||||
|
updateCacheStats(cacheResult);
|
||||||
|
|
||||||
if (cacheResult.returnCode == ValueCache::CacheHit) {
|
if (cacheResult.returnCode == ValueCache::CacheHit) {
|
||||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||||
|
|
@ -1324,6 +1346,7 @@ EvalState::AttrAccesResult EvalState::getOptionalAttrField(Value & attrs, const
|
||||||
};
|
};
|
||||||
|
|
||||||
auto cacheResult = evalCache.getValue(*store, selector, dest);
|
auto cacheResult = evalCache.getValue(*store, selector, dest);
|
||||||
|
updateCacheStats(cacheResult);
|
||||||
|
|
||||||
if (cacheResult.returnCode == ValueCache::CacheHit) {
|
if (cacheResult.returnCode == ValueCache::CacheHit) {
|
||||||
if (cacheResult.lastQueriedSymbolIfMissing)
|
if (cacheResult.lastQueriedSymbolIfMissing)
|
||||||
|
|
@ -2306,6 +2329,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");
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,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;
|
||||||
|
|
@ -355,6 +357,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