I would be interested how it compares in terms of memory needed for evaluation.
I also wanted to know what the impact was so I converted an arbitrary nixpkgs package (github-copilot-cli
) with a package-lock.json
already checked in to git.
Here are the results from NIX_SHOW_STATS=1 nix-instantiate ./. -A github-copilot-cli
:
{
"cpuTime": 0.8051069974899292,
"envs": {
"bytes": 16531624,
"elements": 828921,
"number": 618766
},
"gc": {
"heapSize": 402915328,
"totalBytes": 180765008
},
"list": {
"bytes": 3000672,
"concats": 21613,
"elements": 375084
},
"nrAvoided": 864119,
"nrFunctionCalls": 558479,
"nrLookups": 201175,
"nrOpUpdateValuesCopied": 4886502,
"nrOpUpdates": 45948,
"nrPrimOpCalls": 391174,
"nrThunks": 1152515,
"sets": {
"bytes": 98766016,
"elements": 5996044,
"number": 176832
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 386981,
"number": 37425
},
"values": {
"bytes": 36922296,
"number": 1538429
}
}
{
"cpuTime": 0.34689000248908997,
"envs": {
"bytes": 6537208,
"elements": 330113,
"number": 243519
},
"gc": {
"heapSize": 402915328,
"totalBytes": 63770208
},
"list": {
"bytes": 985664,
"concats": 9249,
"elements": 123208
},
"nrAvoided": 358265,
"nrFunctionCalls": 218872,
"nrLookups": 82271,
"nrOpUpdateValuesCopied": 1712123,
"nrOpUpdates": 18283,
"nrPrimOpCalls": 171800,
"nrThunks": 461449,
"sets": {
"bytes": 33343888,
"elements": 2027896,
"number": 56097
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 246498,
"number": 24916
},
"values": {
"bytes": 13269432,
"number": 552893
}
}
So for single packages we’re looking very good.
But as the cost of the implementation of fetchNpmDeps
amortizes the performance starts to be in favour of that.
I converted a bunch of packages to get a more complete overview with this test expression as my entrypoint:
let
pkgs = import ./. { config.allowUnfree = true; };
in
pkgs.runCommand "all-tests" { } ''
${pkgs.yarn-lock-converter}
${pkgs.github-copilot-cli}
${pkgs.vencord}
${pkgs.osmtogeojson}
${pkgs.netlistsvg}
${pkgs.mongosh}
${pkgs.sunshine}
${pkgs.memos}
''
With that expression the results look like:
{
"cpuTime": 1.1940569877624512,
"envs": {
"bytes": 31789616,
"elements": 1599978,
"number": 1186862
},
"gc": {
"heapSize": 402915328,
"totalBytes": 275616976
},
"list": {
"bytes": 5268080,
"concats": 46200,
"elements": 658510
},
"nrAvoided": 1649593,
"nrFunctionCalls": 1070449,
"nrLookups": 408846,
"nrOpUpdateValuesCopied": 6321984,
"nrOpUpdates": 92526,
"nrPrimOpCalls": 759629,
"nrThunks": 1922521,
"sets": {
"bytes": 130643984,
"elements": 7866524,
"number": 298725
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 392306,
"number": 37863
},
"values": {
"bytes": 62970504,
"number": 2623771
}
}
{
"cpuTime": 1.563081979751587,
"envs": {
"bytes": 41784936,
"elements": 2155619,
"number": 1533749
},
"gc": {
"heapSize": 402915328,
"totalBytes": 274688464
},
"list": {
"bytes": 5585472,
"concats": 81226,
"elements": 698184
},
"nrAvoided": 2160066,
"nrFunctionCalls": 1399176,
"nrLookups": 601130,
"nrOpUpdateValuesCopied": 4680108,
"nrOpUpdates": 143881,
"nrPrimOpCalls": 945377,
"nrThunks": 2258018,
"sets": {
"bytes": 100134000,
"elements": 5937452,
"number": 320923
},
"sizes": {
"Attr": 16,
"Bindings": 16,
"Env": 16,
"Value": 24
},
"symbols": {
"bytes": 469095,
"number": 41044
},
"values": {
"bytes": 70001928,
"number": 2916747
}
}
Of course evaluation performance isn’t everything.
There is a trade-off between faster evaluation and better incrementality & sharing.