Attrset merges are spine-strict when they don't need to be #518
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#518
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When evaluating
(x // { puppy = true; }) ? puppy
, we should not need to evaluate the spine (attrset keys) ofx
. Evaluating the spine can have a significant memory and runtime cost in the case of overlays or large package sets like Nixpkgs.Perhaps this should not throw:
we do have to evaluate attrnames in both operands in all cases because key duplication is an error. delaying this error by making keys lazy would make ux very bad. there have been experiments with this in cppnix (lazy attrs i think it was called), but we're not at all convinced this is sound (let alone a good idea) to not do eagerly.
the performance problem doesn't stem from spine-strictness but from attrset representation in memory being pretty basic. if we could represent attrs not as sorted arrays but as merge trees this problem would go away (and dynamic attrs are evil anyway and should be deleted from the language)
Possibly? It could also cause problems by adding a lot of indirection, depending on how many merges there are in a value and if there's a heuristic for repacking them. I'd love to run an experiment on this. Are we any closer to having performance testing infrastructure?
@rbt I'm sorry I was not able to get performance testing infrastructure yet, if someone could help on this area, that'd be great.
we have a kind of shitty benchmark in-tree but it exists.
Is there a list of things which rely on this and would break if it were dropped?
In my projects I only tend to end up needing them when flattening something to match flake output schema requiring a single attrset instead of nested.
we can immediately think of nixos options docs and numtide/flake-utils, so there's a sizeable base to consider. but a new language version will break those anyway, so it's not a huge hurdle to overcome (especially since all of these uses can be replaced with something more principled, like a new builtin
str -> any -> set
that creates a set from a key and a value)