Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture Nix stats during eval #67

Open
grahamc opened this issue Feb 7, 2018 · 4 comments
Open

Capture Nix stats during eval #67

grahamc opened this issue Feb 7, 2018 · 4 comments

Comments

@grahamc
Copy link
Member

grahamc commented Feb 7, 2018

It would be great to track the Nix evaluation stats over time. An example of these stats are as follows:

grahamc@Morbo> export NIX_SHOW_STATS=1 NIX_COUNT_CALLS=0; cp ../ofborg/ofborg/src/outpaths.nix .; nix-env -f ./outpaths.nix -qaP --no-name --out-path --arg checkMeta true > outs
evaluation statistics:
  time elapsed: 113.927
  size of a value: 24
  size of an attr: 24
  environments allocated: 51021608 (1605585144 bytes)
  list elements: 84838642 (678709136 bytes)
  list concatenations: 5012224
  values allocated: 144000479 (3456011496 bytes)
  sets allocated: 14772174 (4559741232 bytes)
  right-biased unions: 7603556
  values copied in right-biased unions: 130009211
  symbols in symbol table: 288036
  size of symbol table: 11669838
  number of thunks: 97110210
  number of thunks avoided: 85959307
  number of attr lookups: 44963046
  number of primop calls: 35071263
  number of function calls: 45204301
  total allocations: 10300047008 bytes
  current Boehm heap size: 8598323200 bytes
  total Boehm heap allocations: 13792084256 bytes

However, to avoid some ad-hoc parsing of this data, it would be nice if this information could be written out to a separate file, perhaps provided by an environment variable, like NIX_WRITE_STATS=/tmp/nix-eval-stats.

Additionally, it would be cool if it was a bit more simple:

  time elapsed: 113.927
  size of a value: 24
  size of an attr: 24
  environments allocated count: 51021608
  environments allocated bytes: 1605585144
  list elements count: 84838642
  list elements bytes: 678709136
  list concatenations: 5012224
  values allocated count: 144000479
  values allocated bytes: 3456011496
  sets allocated count: 14772174
  sets allocated bytes: 4559741232
  right-biased unions: 7603556
  values copied in right-biased unions: 130009211
  symbols in symbol table: 288036
  size of symbol table: 11669838
  number of thunks: 97110210
  number of thunks avoided: 85959307
  number of attr lookups: 44963046
  number of primop calls: 35071263
  number of function calls: 45204301
  total allocations: 10300047008 bytes
  current Boehm heap size bytes: 8598323200
  total Boehm heap allocations bytes: 13792084256

The code is here: https://github.com/NixOS/nix/blob/master/src/libexpr/eval.cc#L1700

@vcunat
Copy link
Member

vcunat commented Feb 10, 2018

@grahamc
Copy link
Member Author

grahamc commented Feb 10, 2018

Yeah, I'd like to say exactly how a PR changed nixpkgs's evaluation stats during evaluation time. This way we can spot big increases, and celebrate decreases. I suppose I could look at how Hydra captures this data.

@vcunat
Copy link
Member

vcunat commented Feb 10, 2018

Oh, right, even before merging :-) Timings might not be stable enough, but the counts should be sufficient to spot significant regressions.

@grahamc
Copy link
Member Author

grahamc commented Feb 10, 2018

This all started, btw, because I had to bump the initial heap from the default to 4g the other day, and I'd like to catch future big jumps before ofborg is suddenly failing on master.

FRidh added a commit to FRidh/nix that referenced this issue Feb 11, 2018
Flattens the list of statistics as suggested in
NixOS/ofborg#67. This makes it easier to work
with.
@grahamc grahamc mentioned this issue Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants