Mic92 / nixpkgs-review

Review pull-requests on https://github.com/NixOS/nixpkgs
MIT License
390 stars 66 forks source link

Memoize/cache local evals (package list generation) #381

Open Atemu opened 10 months ago

Atemu commented 10 months ago

Local evals take quite a long time, about 2 minutes on my rather fast machine. Often times however, you will have already eval'd some revision before. For example, running two reviews against master after another. Because master is unchanged, it will result in the same eval. If eval was cached/memoized, the local eval time would be halved.

I tried implementing this using joblib.Memory but ran into some roadblocks:

  1. No static access cache dir (i.e. ~/.cache/nixpkgs-review/)
  2. list_packages() takes the nix_path as argument which contains a random file name with the generated overlay which makes it impossible to memoize function args
  3. Unclear what revision we're evaluating when list_packages() is called

To fix #2 we should perhaps look into moving the overlay out of the eval step; allowing everything during package list generation (static .nix file!) and filtering later when figuring out what to build.

Ideally, we could also incorporate ofBorg evals here. For that to happen, we would need ofBorg to produce before and after lists that we could turn into list[Package] but that shouldn't be too hard?

Mic92 commented 10 months ago

Some cache that does dict[commit, list[Packages]] might work. The results could be stored as json. Also using ofborg seems like a good idea.