nix-community / flakelight

Framework for simplifying flake setup [maintainer=@accelbread]
MIT License
177 stars 3 forks source link

Very slow eval compared to pure nixpkgs and flake-parts #8

Closed azuwis closed 5 months ago

azuwis commented 6 months ago

I tried flakelight today, and notice eval is very slow.

Write a small demo to show it.

pure nixpkgs:

$ hyperfine -w 1 'nix --option eval-cache false flake show github:azuwis/flakelight-eval-test/nixpkgs'
Benchmark 1: nix --option eval-cache false flake show github:azuwis/flakelight-eval-test/nixpkgs
  Time (mean ± σ):      1.677 s ±  0.035 s    [User: 0.695 s, System: 0.180 s]
  Range (min … max):    1.592 s …  1.715 s    10 runs

flake-parts:

$ hyperfine -w 1 'nix --option eval-cache false flake show github:azuwis/flakelight-eval-test/flake-parts'
Benchmark 1: nix --option eval-cache false flake show github:azuwis/flakelight-eval-test/flake-parts
  Time (mean ± σ):      1.659 s ±  0.029 s    [User: 0.687 s, System: 0.179 s]
  Range (min … max):    1.620 s …  1.710 s    10 runs

flakelight:

$ hyperfine -w 1 'nix --option eval-cache false flake show github:azuwis/flakelight-eval-test/flakelight' 
Benchmark 1: nix --option eval-cache false flake show github:azuwis/flakelight-eval-test/flakelight
  Time (mean ± σ):     20.198 s ±  0.973 s    [User: 9.464 s, System: 1.527 s]
  Range (min … max):   18.523 s … 22.064 s    10 runs

flakelight take 20s for a simple demo, 10 times slower compared to pure nixpkgs and flake-parts.

All use some nixpkgs version github:NixOS/nixpkgs/cfc3698c31b1fb9cdcf10f36c9643460264d0ca8.

nix-info -m

accelbread commented 6 months ago

Yeah, I can reproduce slow times with those examples. I'll take a look.

I'd expect more time due to building the overlay, but that should not take that long.

accelbread commented 5 months ago

I've pushed commits that speed up evaluation. The largest portion of time was taken by the autodetection of the default package's name, which now should be much faster for most cases.

On my machine, the recent commits bring the measured time of your command down from 15s to around 2s.

Thanks for the report! Since the speed is now reasonable, and I've exhausted the obvious optimizations, I'll close this issue. Feel free to re-open if there is still an issue, or more optimization suggestions.