snix/tvix/eval/src/builtins
Vincent Ambo d91fcd4f28 refactor(tvix/eval): more efficiently intersect attributes
builtins.intersectAttrs is used a _lot_ in nixpkgs eval, for whatever
reason. We previously had a very inefficient implementation that would
allocate for each comparison. It stuck out like a sore thumb in perf
analysis.

This moves to a custom algorithm with two iterators, one for the left
and one for the right side, advancing them along the (borrowed) map
keys until a match is found and allocation is required.

I've not made any effort to reduce the verbosity of this code, I don't
think it's worth it.

On my machine this reduces the mean runtime of evaluating
`nixpkgs.emacs.outPath` by ~8%.

Change-Id: Ie506d82cb8d5f45909628f771a6b73e0eca16b27
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9898
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
2023-11-03 09:24:30 +00:00
..
impure.rs fix(tvix/eval): fix b/281 by adding Value::Catchable 2023-09-24 21:54:10 +00:00
mod.rs refactor(tvix/eval): more efficiently intersect attributes 2023-11-03 09:24:30 +00:00
to_xml.rs fix(tvix/eval): fix b/281 by adding Value::Catchable 2023-09-24 21:54:10 +00:00
versions.rs chore(tvix/eval): fix all current clippy lints 2022-09-29 11:47:47 +00:00