mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 00:39:37 +01:00
Since the only construction and push_back() calls
to Bindings happen through the `BindingsBuilder` [1] we don't
need to keep `capacity` around on the heap anymore. This saves 8 bytes
(because of the member alignment padding)
per one Bindings allocation. This isn't that much, but it does
save significant memory.
This also shows that the Bindings don't necessarily have to
be mutable, which opens up opportunities for doing small bindings
optimization and storing a 1-element Bindings directly in Value.
For the following scenario:
nix-env --query --available --out-path --file ../nixpkgs --eval-system x86_64-linux
(nixpkgs revision: ddcddd7b09a417ca9a88899f4bd43a8edb72308d)
This patch results in reduction of `sets.bytes` 13115104016 -> 12653087640,
which amounts to 462 MB less bytes allocated for Bindings.
[1]: Not actually, `getBuiltins` does mutate bindings, but this is pretty
inconsequential and doesn't lead to problems.
|
||
|---|---|---|
| .. | ||
| data | ||
| pch | ||
| value | ||
| .version | ||
| derived-path.cc | ||
| error_traces.cc | ||
| eval.cc | ||
| json.cc | ||
| main.cc | ||
| meson.build | ||
| nix-meson-build-support | ||
| nix_api_expr.cc | ||
| nix_api_external.cc | ||
| nix_api_value.cc | ||
| nix_api_value_internal.cc | ||
| package.nix | ||
| primops.cc | ||
| search-path.cc | ||
| trivial.cc | ||