1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 20:16:03 +01:00

EvalState: Make the counters atomic

This commit is contained in:
Eelco Dolstra 2025-07-03 13:21:30 +02:00 committed by Jörg Thalheim
parent f3416913d4
commit 8d257f5510
2 changed files with 28 additions and 28 deletions

View file

@ -892,7 +892,7 @@ Value * EvalState::getBool(bool b)
return b ? &Value::vTrue : &Value::vFalse; return b ? &Value::vTrue : &Value::vFalse;
} }
unsigned long nrThunks = 0; static std::atomic<uint64_t> nrThunks = 0;
static inline void mkThunk(Value & v, Env & env, Expr * expr) static inline void mkThunk(Value & v, Env & env, Expr * expr)
{ {
@ -2940,18 +2940,18 @@ void EvalState::printStatistics()
#endif #endif
}; };
topObj["envs"] = { topObj["envs"] = {
{"number", nrEnvs}, {"number", nrEnvs.load()},
{"elements", nrValuesInEnvs}, {"elements", nrValuesInEnvs.load()},
{"bytes", bEnvs}, {"bytes", bEnvs},
}; };
topObj["nrExprs"] = Expr::nrExprs; topObj["nrExprs"] = Expr::nrExprs;
topObj["list"] = { topObj["list"] = {
{"elements", nrListElems}, {"elements", nrListElems.load()},
{"bytes", bLists}, {"bytes", bLists},
{"concats", nrListConcats}, {"concats", nrListConcats.load()},
}; };
topObj["values"] = { topObj["values"] = {
{"number", nrValues}, {"number", nrValues.load()},
{"bytes", bValues}, {"bytes", bValues},
}; };
topObj["symbols"] = { topObj["symbols"] = {
@ -2959,9 +2959,9 @@ void EvalState::printStatistics()
{"bytes", symbols.totalSize()}, {"bytes", symbols.totalSize()},
}; };
topObj["sets"] = { topObj["sets"] = {
{"number", nrAttrsets}, {"number", nrAttrsets.load()},
{"bytes", bAttrsets}, {"bytes", bAttrsets},
{"elements", nrAttrsInAttrsets}, {"elements", nrAttrsInAttrsets.load()},
}; };
topObj["sizes"] = { topObj["sizes"] = {
{"Env", sizeof(Env)}, {"Env", sizeof(Env)},
@ -2969,13 +2969,13 @@ void EvalState::printStatistics()
{"Bindings", sizeof(Bindings)}, {"Bindings", sizeof(Bindings)},
{"Attr", sizeof(Attr)}, {"Attr", sizeof(Attr)},
}; };
topObj["nrOpUpdates"] = nrOpUpdates; topObj["nrOpUpdates"] = nrOpUpdates.load();
topObj["nrOpUpdateValuesCopied"] = nrOpUpdateValuesCopied; topObj["nrOpUpdateValuesCopied"] = nrOpUpdateValuesCopied.load();
topObj["nrThunks"] = nrThunks; topObj["nrThunks"] = nrThunks.load();
topObj["nrAvoided"] = nrAvoided; topObj["nrAvoided"] = nrAvoided.load();
topObj["nrLookups"] = nrLookups; topObj["nrLookups"] = nrLookups.load();
topObj["nrPrimOpCalls"] = nrPrimOpCalls; topObj["nrPrimOpCalls"] = nrPrimOpCalls.load();
topObj["nrFunctionCalls"] = nrFunctionCalls; topObj["nrFunctionCalls"] = nrFunctionCalls.load();
#if NIX_USE_BOEHMGC #if NIX_USE_BOEHMGC
topObj["gc"] = { topObj["gc"] = {
{"heapSize", heapSize}, {"heapSize", heapSize},

View file

@ -961,19 +961,19 @@ private:
*/ */
std::string mkSingleDerivedPathStringRaw(const SingleDerivedPath & p); std::string mkSingleDerivedPathStringRaw(const SingleDerivedPath & p);
unsigned long nrEnvs = 0; std::atomic<uint64_t> nrEnvs = 0;
unsigned long nrValuesInEnvs = 0; std::atomic<uint64_t> nrValuesInEnvs = 0;
unsigned long nrValues = 0; std::atomic<uint64_t> nrValues = 0;
unsigned long nrListElems = 0; std::atomic<uint64_t> nrListElems = 0;
unsigned long nrLookups = 0; std::atomic<uint64_t> nrLookups = 0;
unsigned long nrAttrsets = 0; std::atomic<uint64_t> nrAttrsets = 0;
unsigned long nrAttrsInAttrsets = 0; std::atomic<uint64_t> nrAttrsInAttrsets = 0;
unsigned long nrAvoided = 0; std::atomic<uint64_t> nrAvoided = 0;
unsigned long nrOpUpdates = 0; std::atomic<uint64_t> nrOpUpdates = 0;
unsigned long nrOpUpdateValuesCopied = 0; std::atomic<uint64_t> nrOpUpdateValuesCopied = 0;
unsigned long nrListConcats = 0; std::atomic<uint64_t> nrListConcats = 0;
unsigned long nrPrimOpCalls = 0; std::atomic<uint64_t> nrPrimOpCalls = 0;
unsigned long nrFunctionCalls = 0; std::atomic<uint64_t> nrFunctionCalls = 0;
bool countCalls; bool countCalls;