1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-01 12:37:59 +02:00
nix/src/libexpr
Sergei Zimmerman 5e74c0e4d6
libexpr: Add SampleStack stack-sampling profiler
This patch adds support for a native stack sampling
profiler to the evaluator, which saves a collapsed stack
profile information to a configurable location.

Introduced options (in `EvalSettings`):

- `eval-profile-file` - path to the collected profile file.
- `eval-profiler-frequency` - sampling frequency.
- `eval-profiler` - enumeration option for enabling the profiler.

  Currently only `flamegraph` is supported, but having this an
  enumeration rather than a boolean switch leaves the door open
  for other profiler variants (e.g. tracy).

Profile includes the following information on best-effort basis (e.g. some lambdas might
have an undefined name). Callstack information contains:

- Call site location (where the function gets called).
- Primop/lambda name of the function being called.
- Functors/partial applications don't have a name attached to them unlike special-cased primops and lambads.

For cases where callsite location isn't available we have to resort to providing
the location where the lambda itself is defined. This removes some of the confusing
`«none»:0` locations in the profile from previous attempts.

Example usage with piping directly into zstd for compression:

```
nix eval --no-eval-cache nixpkgs#nixosTests.gnome \
  --eval-profiler flamegraph \
  --eval-profile-file >(zstd -of nix.profile.zstd)
```

Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
2025-05-21 20:15:19 +00:00
..
include/nix/expr libexpr: Add SampleStack stack-sampling profiler 2025-05-21 20:15:19 +00:00
primops Remove global fetcher cache 2025-05-17 19:54:32 +02:00
value Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
.version Meson build for libexpr and libflake 2024-07-02 09:23:24 -04:00
attr-path.cc treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
attr-set.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
eval-cache.cc treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
eval-error.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
eval-gc.cc Add -Wundef to make #if FOO an error if not defined 2025-04-05 00:45:19 +02:00
eval-profiler-settings.cc libexpr: Add SampleStack stack-sampling profiler 2025-05-21 20:15:19 +00:00
eval-profiler.cc libexpr: Add SampleStack stack-sampling profiler 2025-05-21 20:15:19 +00:00
eval-settings.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
eval.cc libexpr: Add SampleStack stack-sampling profiler 2025-05-21 20:15:19 +00:00
fetchurl.nix Format .nix files 2025-01-24 17:04:02 +01:00
function-trace.cc libexpr: Use EvalProfiler for FunctionCallTrace 2025-05-18 11:55:39 +00:00
get-drvs.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
imported-drv-to-derivation.nix Format .nix files 2025-01-24 17:04:02 +01:00
json-to-value.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
lexer-helpers.cc Make lexer-helpers.hh internal to fix a clang-tidy error 2025-04-07 18:21:08 +02:00
lexer-helpers.hh Make lexer-helpers.hh internal to fix a clang-tidy error 2025-04-07 18:21:08 +02:00
lexer.l libexpr: Improve lexer performance by using full scanner tables (-Cf) 2025-05-01 23:10:04 +00:00
meson.build libexpr: Add SampleStack stack-sampling profiler 2025-05-21 20:15:19 +00:00
meson.options Meson build for libexpr and libflake 2024-07-02 09:23:24 -04:00
nix-meson-build-support rename: build-utils-meson -> nix-meson-build-support 2024-12-09 16:54:42 +01:00
nixexpr.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
package.nix Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
parser.y Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
paths.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
primops.cc libexpr: Use attrs.alreadySorted() in primop_functionArgs 2025-05-19 19:53:20 +00:00
print-ambiguous.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
print.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
search-path.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
value-to-json.cc Docs 2025-04-02 18:02:32 +02:00
value-to-xml.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00