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

Make Nix eval stats more easily machine-parsable #1858

Closed
grahamc opened this issue Feb 10, 2018 · 2 comments
Closed

Make Nix eval stats more easily machine-parsable #1858

grahamc opened this issue Feb 10, 2018 · 2 comments
Assignees
Labels
error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc UX The way in which users interact with Nix. Higher level than UI.

Comments

@grahamc
Copy link
Member

grahamc commented Feb 10, 2018

The following is a cross-post issue from NixOS/ofborg#67.

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

Hydra implements the metric gathering using a call inside a nix-build (https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/metrics.nix#L22) , however the ofborg evaluator doesn't build anything at all (and I'd like to keep it that way.)

@stale
Copy link

stale bot commented Feb 14, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 14, 2021
@fricklerhandwerk fricklerhandwerk added UX The way in which users interact with Nix. Higher level than UI. error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc and removed improvement labels Sep 13, 2022
@stale stale bot removed stale labels Sep 13, 2022
@roberth
Copy link
Member

roberth commented Mar 16, 2024

Nix will put it in a JSON file with NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=file.json. This functionality has been available for some time now.

If it's not documented, it's not done, but the documentation problem is better described by

@roberth roberth closed this as completed Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

No branches or pull requests

5 participants