-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization for name value pair attribute sets #7676
Comments
What's extra here is having multiple implementations of the attrset interface, which has its own cost. Some thoughts:
That's all I have for now, but I'll conclude that it's worth trying. If this shows that a " |
Oh yeah, also #4090 would benefit from an abstracted attribute representation. I didn't have the time for it, but that's what I wanted to do next for that PR. Specifically I think that should be an explicit |
I was curious what the impact of such an optimization would be and measured a nixpkgs eval.
{
"cpuTime": 712.0946655273438,
"envs": {
"bytes": 17685813200,
"elements": 923836208,
"number": 643445221
},
"gc": {
"heapSize": 49061007360,
"totalBytes": 104299666128
},
"list": {
"bytes": 2495572504,
"concats": 54666602,
"elements": 311946563
},
"nrAvoided": 784922249,
"nrExprs": 3814091,
"nrFunctionCalls": 599839037,
"nrLookups": 315198579,
"nrOpUpdateValuesCopied": 1507273801,
"nrOpUpdates": 70052121,
"nrPrimOpCalls": 296204095,
"nrThunks": 849099332,
"sets": {
"bytes": 33392546032,
"elements": 1966117714,
"number": 120916413
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 2095785,
"number": 158751
},
"values": {
"bytes": 26435170488,
"number": 1101465437
}
} Number of key value pairs created by lib.nameValuePair550616 Attrset size distributionI think these numbers point to that there are some performance outliers to find in nixpkgs. List very long and disruptive, click to expand.Rendered as right-aligned because it better points out the outliers.
|
Is your feature request related to a problem? Please describe.
Name-value pairs like
{ name = "..."; value = "..."; }
are frequently used, especially when converting between attribute sets and lists usingbuiltins.listToAttrs
andlib.mapAttrsToList lib.nameValuePair
. It would be beneficial for these operations to be optimized.Describe the solution you'd like
It should be possible to implement an optimization for such values by storing the
name
andvalue
directly in theValue
union, just like how lists of sizes <= 2 are.Ping @roberth
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: