Skip to content

[Backport 2.32-maintenance] libexpr: Speed up BindingsBuilder::finishSizeIfNecessary#14372

Merged
edolstra merged 1 commit into2.32-maintenancefrom
backport-14362-to-2.32-maintenance
Oct 27, 2025
Merged

[Backport 2.32-maintenance] libexpr: Speed up BindingsBuilder::finishSizeIfNecessary#14372
edolstra merged 1 commit into2.32-maintenancefrom
backport-14362-to-2.32-maintenance

Conversation

@internal-nix-ci
Copy link

Automatic backport to 2.32-maintenance, triggered by a label in #14362.

Instead of iterating over the newly built bindings we can
do a cheaper set_intersection to count duplicates or fall back
to a per-element binary search over the "base" bindings.

This speeds up `hello` evaluation by around 10ms (0.196s -> 0.187s) and
`nixos.closures.ec2.x86_64-linux` by 140ms (2.744s -> 2.609s).

This addresses a somewhat steep performance regression from 82315c3
that reduced memory requirements of attribute set merges. With this patch
we get back around to 2.31 level of eval performance while keeping the memory
usage optimization.

Also document the optimization a bit more.

(cherry picked from commit ec2fd2d)
@edolstra
Copy link
Member

Not sure if we should backport this, unless it's a fix to a major performance regression.

@xokdvium
Copy link
Contributor

Not sure if we should backport this

Generally it's a very safe change without any functional differences and the performance uplift will help a lot in nixpkgs CI. I think @wolfgangwalther and @philiptaron will agree that it's substantial enough that it warrants a backport.

@philiptaron
Copy link
Contributor

We can judge the impact on Nixpkgs CI within the week, but I'll leave it to the Nix team to decide if backporting is the right call.

@edolstra edolstra merged commit 291e8ab into 2.32-maintenance Oct 27, 2025
19 checks passed
@edolstra edolstra deleted the backport-14362-to-2.32-maintenance branch October 27, 2025 15:41
@wolfgangwalther
Copy link
Contributor

I can't comment on how safe the change is or not or whether it fully fixes the performance regression. But I can say that it would be very much appreciated to fix that regression in Nixpkgs quickly. I think that means I am 👍 on a backport ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants