mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Move EvalState from the stack to the heap
EvalState contains a few counters (e.g. nrValues) that increase quickly enough that they end up being interpreted as pointers by the garbage collector. Moving it to the heap makes them invisible to the garbage collector. This reduces the max RSS doing 100 evaluations of nixos.tests.firefox.x86_64-linux.drvPath from 455 MiB to 292 MiB. Note: ideally, allocations would be much further up in the 64-bit address space to reduce the odds of an integer being misinterpreted as a pointer. Maybe we can use some linker magic to move the .bss segment to a higher address.
This commit is contained in:
parent
c905d8b0a8
commit
0629601da1
5 changed files with 46 additions and 46 deletions
|
@ -158,16 +158,16 @@ int main(int argc, char * * argv)
|
|||
|
||||
auto store = openStore();
|
||||
|
||||
EvalState state(myArgs.searchPath, store);
|
||||
state.repair = repair;
|
||||
auto state = std::make_unique<EvalState>(myArgs.searchPath, store);
|
||||
state->repair = repair;
|
||||
|
||||
Bindings & autoArgs = *myArgs.getAutoArgs(state);
|
||||
Bindings & autoArgs = *myArgs.getAutoArgs(*state);
|
||||
|
||||
if (attrPaths.empty()) attrPaths = {""};
|
||||
|
||||
if (findFile) {
|
||||
for (auto & i : files) {
|
||||
Path p = state.findFile(i);
|
||||
Path p = state->findFile(i);
|
||||
if (p == "") throw Error(format("unable to find '%1%'") % i);
|
||||
std::cout << p << std::endl;
|
||||
}
|
||||
|
@ -175,20 +175,20 @@ int main(int argc, char * * argv)
|
|||
}
|
||||
|
||||
if (readStdin) {
|
||||
Expr * e = state.parseStdin();
|
||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||
Expr * e = state->parseStdin();
|
||||
processExpr(*state, attrPaths, parseOnly, strict, autoArgs,
|
||||
evalOnly, outputKind, xmlOutputSourceLocation, e);
|
||||
} else if (files.empty() && !fromArgs)
|
||||
files.push_back("./default.nix");
|
||||
|
||||
for (auto & i : files) {
|
||||
Expr * e = fromArgs
|
||||
? state.parseExprFromString(i, absPath("."))
|
||||
: state.parseExprFromFile(resolveExprPath(state.checkSourcePath(lookupFileArg(state, i))));
|
||||
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||
? state->parseExprFromString(i, absPath("."))
|
||||
: state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state, i))));
|
||||
processExpr(*state, attrPaths, parseOnly, strict, autoArgs,
|
||||
evalOnly, outputKind, xmlOutputSourceLocation, e);
|
||||
}
|
||||
|
||||
state.printStats();
|
||||
state->printStats();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue