Skip to content

add derivation parser benchmark#13569

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
Mic92:benchmark
Jul 29, 2025
Merged

add derivation parser benchmark#13569
Ericson2314 merged 1 commit intoNixOS:masterfrom
Mic92:benchmark

Conversation

@Mic92
Copy link
Member

@Mic92 Mic92 commented Jul 29, 2025

the current identified bottlenecks are parseString in derivations.cc and dirOf (because of std::filessystem creation).

@Mic92
Copy link
Member Author

Mic92 commented Jul 29, 2025

So this line is expensive:

return std::filesystem::path{path}.parent_path().string();

And this function is hot:
for (; c != end && *c != '"'; c++) {

This is what I did in rust: https://github.com/Mic92/nix-diff-rs/blob/bd5d3d2ba4470b3b4a9acddcd0d5ba9968235416/src/parser.rs#L181

What is the equivalent of memchr2 in C++?

description : 'Build language bindings (e.g. Perl)',
)

option(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this option is not the right approach w.r.t. componentized builds? It works in a devshell only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add the option only to the subprojects that have benchmarks and make that option yield?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could move benchmarks to its own subprojects maybe? Or we just always build them but not run them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could move benchmarks to its own subprojects maybe

Not sure if it's warranted for now. Can we stick with just 2 options: in libstore-tests and the top-level file, and the one in libstore-tests with yield: true.

Or we just always build them but not run them.

Not a huge fan, because we'd have an unconditional dep on gbenchmark in nixpkgs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we just always build them but not run them.

Not a huge fan, because we'd have an unconditional dep on gbenchmark in nixpkgs.

Does the componentized build help here? We would always build the benchmarks, but we don't have to run time, and the thing users actually install won't depend on them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would always build the benchmarks, but we don't have to run time, and the thing users actually install won't depend on them.

Makes sense, yeah. I suppose introducing configurability isn't a top priority here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can merge this now, and maybe then consider removing the flags.

@Mic92 Mic92 force-pushed the benchmark branch 4 times, most recently from a0f1e70 to a625739 Compare July 29, 2025 14:42
the current identified bottlenecks are parseString in derivations.cc and dirOf (because of std::filessystem creation).
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/getting-started-with-optimizing-the-nix-project/67342/1

Copy link
Contributor

@xokdvium xokdvium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good start. Very excited about improved tooling. We can improve on it in follow-ups.

@Ericson2314 Ericson2314 merged commit b062730 into NixOS:master Jul 29, 2025
14 checks passed
@Mic92 Mic92 deleted the benchmark branch July 29, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants