1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-17 14:31:06 +01:00
nix/src
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
..
build-remote Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
external-api-docs Format .nix files 2025-01-24 17:04:02 +01:00
internal-api-docs Format .nix files 2025-01-24 17:04:02 +01:00
libcmd Merge pull request #13224 from NixOS/nix-profile-add 2025-05-20 20:15:31 +02:00
libexpr libexpr: Add SampleStack stack-sampling profiler 2025-05-21 20:15:19 +00:00
libexpr-c Docs 2025-04-02 18:02:32 +02:00
libexpr-test-support Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libexpr-tests libexpr: fix UB in builtins.ceil and builtins.floor 2025-04-13 04:36:09 +02:00
libfetchers Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
libfetchers-c nix-fetchers-c: Init with settings object 2025-04-02 18:29:42 +02:00
libfetchers-tests Drop fs alias in favour of std::filesystem 2025-05-01 14:24:34 +02:00
libflake Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
libflake-c Fix flake-c out of bounds access 2025-04-25 17:07:32 +02:00
libflake-tests nix-flake-c: Add lock flags 2025-04-02 18:29:42 +02:00
libmain treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
libmain-c Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libstore Merge pull request #13177 from obsidiansystems/less-useDerivation 2025-05-20 11:39:48 -04:00
libstore-c Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
libstore-test-support Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
libstore-tests libstore: Introduce WorkerProto::FeatureSet alias 2025-05-02 17:40:34 +00:00
libutil Use transparent comparators for StringMap and StringPairs 2025-05-19 20:38:19 +00:00
libutil-c Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
libutil-test-support Merge pull request #12877 from roberth/c-api-libflake-override-input 2025-04-08 09:01:51 +02:00
libutil-tests Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
nix Merge pull request #13224 from NixOS/nix-profile-add 2025-05-20 20:15:31 +02:00
nix-build Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
nix-channel Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
nix-collect-garbage Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
nix-copy-closure Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
nix-env Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
nix-instantiate Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
nix-store Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
perl Split out store-open.hh and store-registration.hh 2025-05-14 16:07:57 -04:00
nix-functional-tests Build Functional tests with Meson 2024-08-14 15:35:40 -04:00
nix-manual Build the manual with Meson 2024-10-09 11:58:17 -04:00