nix-community / nix-index

Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance optimisation

SuperSandro2000 opened this issue · comments

I generated a flame graph with the help of https://www.justanotherdot.com/posts/profiling-with-perf-and-dhat-on-rust-code-in-linux.html and the nix-index database from https://github.com/nix-community/nix-index-database .

One thing you notice immediately is that we spend a lot of the time (43.5%) on decoding the highly compressed zstd. Maybe lowering the compression level from 22 (!) to some more default value like 9 can already increase performance with only small database increases.

My general idea with this is to kickoff performance optimisations to make nix-index faster when using as a command-not-found replacement.

profile

 ▶ time target/release/nix-locate bin/hello
......

real    0m1.545s
user    0m1.375s
sys     0m0.150s