mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +01:00
Looking at perf:
0.21 │ push %rbp
0.99 │ mov %rsp,%rbp
│ push %r15
0.25 │ push %r14
│ push %r13
0.49 │ push %r12
0.66 │ push %rbx
1.23 │ lea -0x10000(%rsp),%r11
0.23 │ 15: sub $0x1000,%rsp
1.01 │ orq $0x0,(%rsp)
59.12 │ cmp %r11,%rsp
0.27 │ ↑ jne 15
Seems like 64K is too much to have on the stack for each invocation, considering
that only a minuscule number of allocations are actually larger than 4K.
There's actually no good reason this function should use so much stack space. Or
use small_string at all. Everything can be done in small chunks that don't require
any memory allocations and use up 2K bytes on the stack.
This patch also adds a microbenchmark for tracking the unparsing performance. Here
are the results for this change:
(Before)
BM_UnparseRealDerivationFile/hello 7275 ns 7247 ns 96093 bytes_per_second=232.136Mi/s
BM_UnparseRealDerivationFile/firefox 40538 ns 40376 ns 17327 bytes_per_second=378.534Mi/s
(After)
BM_UnparseRealDerivationFile/hello 3228 ns 3218 ns 215671 bytes_per_second=522.775Mi/s
BM_UnparseRealDerivationFile/firefox 39724 ns 39584 ns 17617 bytes_per_second=386.101Mi/s
This translates into nice evaluation performance improvements (compared to
|
||
|---|---|---|
| .. | ||
| data | ||
| pch | ||
| .version | ||
| bench-main.cc | ||
| common-protocol.cc | ||
| content-address.cc | ||
| derivation-advanced-attrs.cc | ||
| derivation-parser-bench.cc | ||
| derivation.cc | ||
| derived-path.cc | ||
| downstream-placeholder.cc | ||
| http-binary-cache-store.cc | ||
| legacy-ssh-store.cc | ||
| local-binary-cache-store.cc | ||
| local-overlay-store.cc | ||
| local-store.cc | ||
| machines.cc | ||
| meson.build | ||
| meson.options | ||
| nar-info-disk-cache.cc | ||
| nar-info.cc | ||
| nix-meson-build-support | ||
| nix_api_store.cc | ||
| outputs-spec.cc | ||
| package.nix | ||
| path-info.cc | ||
| path.cc | ||
| ref-scan-bench.cc | ||
| references.cc | ||
| s3-binary-cache-store.cc | ||
| s3.cc | ||
| serve-protocol.cc | ||
| ssh-store.cc | ||
| store-reference.cc | ||
| uds-remote-store.cc | ||
| worker-protocol.cc | ||