nix-super/src/libstore
Jade Lovelace 473d2d56fc Remove 100s of CPU time (10%) from build times (1465s -> 1302s)
Result's from Mic92's framework 13th Gen Intel Core i7-1360P:

Before: 3595.92s user 183.01s system 1360% cpu 4:37.74 total
After: 3486.07s user 168.93s system 1354% cpu 4:29.79 total

I saw that boost/lexical_cast was costing about 100s in CPU time on our
compiles. We can fix this trivially by doing explicit template
instantiation in exactly one place and eliminating all other includes of
it, which is a code improvement anyway by hiding the boost.

Before:
```
lix/lix2 » ClangBuildAnalyzer --analyze buildtimeold.bin
Analyzing build trace from 'buildtimeold.bin'...
**** Time summary:
Compilation (551 times):
  Parsing (frontend):         1465.3 s
  Codegen & opts (backend):   1110.9 s

<snip>

**** Expensive headers:
178153 ms: ../src/libcmd/installable-value.hh (included 52 times, avg 3426 ms), included via:
  40x: command.hh
  5x: command-installable-value.hh
  3x: installable-flake.hh
  2x: <direct include>
  2x: installable-attr-path.hh

176217 ms: ../src/libutil/error.hh (included 246 times, avg 716 ms), included via:
  36x: command.hh installable-value.hh installables.hh derived-path.hh config.hh experimental-features.hh
  12x: globals.hh config.hh experimental-features.hh
  11x: file-system.hh file-descriptor.hh
  6x: serialise.hh strings.hh
  6x: <direct include>
  6x: archive.hh serialise.hh strings.hh
  ...

173243 ms: ../src/libstore/store-api.hh (included 152 times, avg 1139 ms), included via:
  55x: <direct include>
  39x: command.hh installable-value.hh installables.hh
  7x: libexpr.hh
  4x: local-store.hh
  4x: command-installable-value.hh installable-value.hh installables.hh
  3x: binary-cache-store.hh
  ...

170482 ms: ../src/libutil/serialise.hh (included 201 times, avg 848 ms), included via:
  37x: command.hh installable-value.hh installables.hh built-path.hh realisation.hh hash.hh
  14x: store-api.hh nar-info.hh hash.hh
  11x: <direct include>
  7x: primops.hh eval.hh attr-set.hh nixexpr.hh value.hh source-path.hh archive.hh
  7x: libexpr.hh value.hh source-path.hh archive.hh
  6x: fetchers.hh hash.hh
  ...

169397 ms: ../src/libcmd/installables.hh (included 53 times, avg 3196 ms), included via:
  40x: command.hh installable-value.hh
  5x: command-installable-value.hh installable-value.hh
  3x: installable-flake.hh installable-value.hh
  2x: <direct include>
  1x: installable-derived-path.hh
  1x: installable-value.hh
  ...

159740 ms: ../src/libutil/strings.hh (included 221 times, avg 722 ms), included via:
  37x: command.hh installable-value.hh installables.hh built-path.hh realisation.hh hash.hh serialise.hh
  19x: <direct include>
  14x: store-api.hh nar-info.hh hash.hh serialise.hh
  11x: serialise.hh
  7x: primops.hh eval.hh attr-set.hh nixexpr.hh value.hh source-path.hh archive.hh serialise.hh
  7x: libexpr.hh value.hh source-path.hh archive.hh serialise.hh
  ...

156796 ms: ../src/libcmd/command.hh (included 51 times, avg 3074 ms), included via:
  42x: <direct include>
  7x: command-installable-value.hh
  2x: installable-attr-path.hh

150392 ms: ../src/libutil/types.hh (included 251 times, avg 599 ms), included via:
  36x: command.hh installable-value.hh installables.hh path.hh
  11x: file-system.hh
  10x: globals.hh
  6x: fetchers.hh
  6x: serialise.hh strings.hh error.hh
  5x: archive.hh
  ...

133101 ms: /nix/store/644b90j1vms44nr18yw3520pzkrg4dd1-boost-1.81.0-dev/include/boost/lexical_cast.hpp (included 226 times, avg 588 ms), included via
:
  37x: command.hh installable-value.hh installables.hh built-path.hh realisation.hh hash.hh serialise.hh strings.hh
  19x: file-system.hh
  11x: store-api.hh nar-info.hh hash.hh serialise.hh strings.hh
  7x: primops.hh eval.hh attr-set.hh nixexpr.hh value.hh source-path.hh archive.hh serialise.hh strings.hh
  7x: libexpr.hh value.hh source-path.hh archive.hh serialise.hh strings.hh
  6x: eval.hh attr-set.hh nixexpr.hh value.hh source-path.hh archive.hh serialise.hh strings.hh
  ...

132887 ms: /nix/store/h2abv2l8irqj942i5rq9wbrj42kbsh5y-gcc-12.3.0/include/c++/12.3.0/memory (included 262 times, avg 507 ms), included via:
  36x: command.hh installable-value.hh installables.hh path.hh types.hh ref.hh
  16x: gtest.h
  11x: file-system.hh types.hh ref.hh
  10x: globals.hh types.hh ref.hh
  10x: json.hpp
  6x: serialise.hh
  ...

  done in 0.6s.
```

After:
```
lix/lix2 » maintainers/buildtime_report.sh build
Processing all files and saving to '/home/jade/lix/lix2/maintainers/../buildtime.bin'...
  done in 0.6s. Run 'ClangBuildAnalyzer --analyze /home/jade/lix/lix2/maintainers/../buildtime.bin' to analyze it.
Analyzing build trace from '/home/jade/lix/lix2/maintainers/../buildtime.bin'...
**** Time summary:
Compilation (551 times):
  Parsing (frontend):         1302.1 s
  Codegen & opts (backend):    956.3 s

<snip>

**** Expensive headers:
178145 ms: ../src/libutil/error.hh (included 246 times, avg 724 ms), included via:
  36x: command.hh installable-value.hh installables.hh derived-path.hh config.hh experimental-features.hh
  12x: globals.hh config.hh experimental-features.hh
  11x: file-system.hh file-descriptor.hh
  6x: <direct include>
  6x: serialise.hh strings.hh
  6x: fetchers.hh hash.hh serialise.hh strings.hh
  ...

154043 ms: ../src/libcmd/installable-value.hh (included 52 times, avg 2962 ms), included via:
  40x: command.hh
  5x: command-installable-value.hh
  3x: installable-flake.hh
  2x: <direct include>
  2x: installable-attr-path.hh

153593 ms: ../src/libstore/store-api.hh (included 152 times, avg 1010 ms), included via:
  55x: <direct include>
  39x: command.hh installable-value.hh installables.hh
  7x: libexpr.hh
  4x: local-store.hh
  4x: command-installable-value.hh installable-value.hh installables.hh
  3x: binary-cache-store.hh
  ...

149948 ms: ../src/libutil/types.hh (included 251 times, avg 597 ms), included via:
  36x: command.hh installable-value.hh installables.hh path.hh
  11x: file-system.hh
  10x: globals.hh
  6x: fetchers.hh
  6x: serialise.hh strings.hh error.hh
  5x: archive.hh
  ...

144560 ms: ../src/libcmd/installables.hh (included 53 times, avg 2727 ms), included via:
  40x: command.hh installable-value.hh
  5x: command-installable-value.hh installable-value.hh
  3x: installable-flake.hh installable-value.hh
  2x: <direct include>
  1x: installable-value.hh
  1x: installable-derived-path.hh
  ...

136585 ms: ../src/libcmd/command.hh (included 51 times, avg 2678 ms), included via:
  42x: <direct include>
  7x: command-installable-value.hh
  2x: installable-attr-path.hh

133394 ms: /nix/store/h2abv2l8irqj942i5rq9wbrj42kbsh5y-gcc-12.3.0/include/c++/12.3.0/memory (included 262 times, avg 509 ms), included via:
  36x: command.hh installable-value.hh installables.hh path.hh types.hh ref.hh
  16x: gtest.h
  11x: file-system.hh types.hh ref.hh
  10x: globals.hh types.hh ref.hh
  10x: json.hpp
  6x: serialise.hh
  ...

89315 ms: ../src/libstore/derived-path.hh (included 178 times, avg 501 ms), included via:
  37x: command.hh installable-value.hh installables.hh
  25x: store-api.hh realisation.hh
  7x: primops.hh eval.hh attr-set.hh nixexpr.hh value.hh context.hh
  6x: eval.hh attr-set.hh nixexpr.hh value.hh context.hh
  6x: libexpr.hh value.hh context.hh
  6x: shared.hh
  ...

87347 ms: /nix/store/h2abv2l8irqj942i5rq9wbrj42kbsh5y-gcc-12.3.0/include/c++/12.3.0/ostream (included 273 times, avg 319 ms), included via:
  35x: command.hh installable-value.hh installables.hh path.hh types.hh ref.hh memory unique_ptr.h
  12x: regex sstream istream
  10x: file-system.hh types.hh ref.hh memory unique_ptr.h
  10x: gtest.h memory unique_ptr.h
  10x: globals.hh types.hh ref.hh memory unique_ptr.h
  6x: fetchers.hh types.hh ref.hh memory unique_ptr.h
  ...

85249 ms: ../src/libutil/config.hh (included 213 times, avg 400 ms), included via:
  37x: command.hh installable-value.hh installables.hh derived-path.hh
  20x: globals.hh
  20x: logging.hh
  16x: store-api.hh logging.hh
  6x: <direct include>
  6x: eval.hh attr-set.hh nixexpr.hh value.hh context.hh derived-path.hh
  ...

  done in 0.5s.
```

Adapated from 18aa3e1d57
2024-05-31 13:00:09 +02:00
..
build More work on the scheduler for windows 2024-05-28 11:39:49 -04:00
builtins inline the usage of nix::readDirectory 2024-05-12 17:42:18 +05:30
linux libstore/local-derivation-goal: prohibit creating setuid/setgid binaries 2024-04-18 12:20:20 +02:00
unix More work on the scheduler for windows 2024-05-28 11:39:49 -04:00
windows Merge pull request #10678 from nix-windows/windows-substitution-goal 2024-05-27 17:47:29 -04:00
binary-cache-store.cc Remove 100s of CPU time (10%) from build times (1465s -> 1302s) 2024-05-31 13:00:09 +02:00
binary-cache-store.hh Use SourcePath in more places 2024-05-06 19:05:42 +02:00
build-result.cc Test the rest of the worker protocol serializers 2023-10-04 15:31:52 -04:00
build-result.hh Fix gcc 12 warnings 2024-02-28 22:59:20 +01:00
builtins.hh builtin:{unpack-channel,buildenv}: Get output path from the derivation 2024-02-12 16:34:59 +01:00
ca-specific-schema.sql Build the local store on Windows 2024-05-10 13:05:23 -04:00
common-protocol-impl.hh Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
common-protocol.cc Merge pull request #6236 from obsidiansystems/store-dir-config 2023-12-01 15:38:14 +01:00
common-protocol.hh Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
content-address.cc Add Git object hashing to the store layer 2024-02-27 11:27:34 -05:00
content-address.hh treewide: hash type -> hash algorithm 2024-02-26 18:09:06 +08:00
daemon.cc Remove 100s of CPU time (10%) from build times (1465s -> 1302s) 2024-05-31 13:00:09 +02:00
daemon.hh Add Store::isTrustedClient() 2023-04-06 19:59:57 -04:00
derivations.cc Require drvPath attribute to end with .drv 2024-05-22 12:50:24 -04:00
derivations.hh refactor: Impure derivation type isPure -> isImpure 2024-01-27 11:00:10 +01:00
derived-path-map.cc Split up util.{hh,cc} 2023-11-05 12:20:02 -05:00
derived-path-map.hh Split up util.{hh,cc} 2023-11-05 12:20:02 -05:00
derived-path.cc use std::tie() for macro-generated operators 2023-12-19 19:32:16 +01:00
derived-path.hh Merge pull request #6236 from obsidiansystems/store-dir-config 2023-12-01 15:38:14 +01:00
downstream-placeholder.cc Renamed HashFormat::Base32 to HashFormat::Nix32 2023-12-06 23:43:42 +01:00
downstream-placeholder.hh Introduce OutputName and OutputNameView type aliases 2023-08-25 09:55:07 -04:00
dummy-store.cc Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
dummy-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
export-import.cc ParseSink -> FileSystemObjectSink 2024-01-22 18:01:18 -05:00
filetransfer.cc tryUnshareFilesystem: Ignore ENOSYS too 2024-05-22 16:07:38 -04:00
filetransfer.hh Tarball fetcher: Use the content-addressed Git cache 2024-02-20 12:57:36 +01:00
gc-store.hh Clean up store hierarchy with IndirectRootStore 2023-07-24 09:19:44 -04:00
gc.cc Improve nix-store --delete failure message 2024-05-17 18:20:22 +02:00
globals.cc inline the usage of nix::readDirectory 2024-05-12 17:42:18 +05:30
globals.hh Document file system object content addressing 2024-05-15 16:28:48 -04:00
http-binary-cache-store.cc Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
http-binary-cache-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
indirect-root-store.cc inline the usage of nix::renameFile 2024-05-12 18:40:16 +05:30
indirect-root-store.hh Enable the unix:// store on Windows 2024-04-18 16:58:32 -04:00
keys.cc Separate SystemError from SysError 2024-01-12 12:00:33 -05:00
keys.hh Signer infrastructure: Prep for #9076 2024-01-03 16:13:55 -05:00
legacy-ssh-store.cc Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
legacy-ssh-store.hh Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
legacy-ssh-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
length-prefixed-protocol-helper.hh Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
local-binary-cache-store.cc Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
local-binary-cache-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
local-fs-store.cc nix shell: Handle output paths that are symlinks 2024-04-10 23:49:19 +02:00
local-fs-store.hh Add Git object hashing to the store layer 2024-02-27 11:27:34 -05:00
local-store.cc Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
local-store.hh Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
local-store.md Build the local store on Windows 2024-05-10 13:05:23 -04:00
local.mk Start building the scheduler for Windows 2024-05-10 20:23:59 -04:00
log-store.cc Move the getBuildLog implementation to its own implementation file 2023-01-13 11:05:44 +01:00
log-store.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
machines.cc Remove 100s of CPU time (10%) from build times (1465s -> 1302s) 2024-05-31 13:00:09 +02:00
machines.hh Restore exposing machine file parsing 2024-05-23 00:03:52 -04:00
make-content-addressed.cc HashType: Rename to HashAlgorithm 2023-12-06 23:43:42 +01:00
make-content-addressed.hh makeContentAddressed: Add single path helper 2023-06-30 18:22:47 +02:00
misc.cc Build a minimized Nix with MinGW 2024-04-17 12:26:10 -04:00
mounted-ssh-store.md MountedSSHStore: stores on shared filesystems 2023-11-21 13:34:01 -05:00
names.cc return string_views from forceString* 2022-01-27 17:15:43 +01:00
names.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
nar-accessor.cc CanonPath, SourcePath: Change operator + to / 2024-02-05 15:17:39 +01:00
nar-accessor.hh Fix consts and casts 2023-11-08 17:29:55 +01:00
nar-info-disk-cache.cc Update nar-info-disk-cache.cc 2024-02-12 23:37:40 +03:00
nar-info-disk-cache.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
nar-info.cc Improve checked json casting (#10087) 2024-04-03 18:04:00 +00:00
nar-info.hh Fix consts and casts 2023-11-08 17:29:55 +01:00
nix-store.pc.in Fix building with GCC 9 2023-02-10 18:38:57 +01:00
optimise-store.cc Build the local store on Windows 2024-05-10 13:05:23 -04:00
outputs-spec.cc Fix moves that accidentally copy anyway 2023-10-16 21:48:35 +01:00
outputs-spec.hh Introduce OutputName and OutputNameView type aliases 2023-08-25 09:55:07 -04:00
parsed-derivations.cc Fix exportReferencesGraph when given store subpath 2024-04-17 21:51:59 +02:00
parsed-derivations.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
path-info.cc Improve checked json casting (#10087) 2024-04-03 18:04:00 +00:00
path-info.hh Signer infrastructure: Prep for #9076 2024-01-03 16:13:55 -05:00
path-references.cc HashType: Rename to HashAlgorithm 2023-12-06 23:43:42 +01:00
path-references.hh Split up util.{hh,cc} 2023-11-05 12:20:02 -05:00
path-regex.hh Disallow store path names that are . or .. (plus opt. -) 2024-01-31 18:35:19 +01:00
path-with-outputs.cc Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
path-with-outputs.hh Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
path.cc Require drvPath attribute to end with .drv 2024-05-22 12:50:24 -04:00
path.hh Require drvPath attribute to end with .drv 2024-05-22 12:50:24 -04:00
pathlocks.cc Create no-op Window pathlocks implementation 2024-04-17 11:48:14 -04:00
pathlocks.hh Pathlocks Implementation for Windows (#10586) 2024-04-22 15:08:10 +00:00
posix-fs-canonicalise.cc inline the usage of nix::readDirectory 2024-05-12 17:42:18 +05:30
posix-fs-canonicalise.hh Build the local store on Windows 2024-05-10 13:05:23 -04:00
profiles.cc inline the usage of nix::readDirectory 2024-05-12 17:42:18 +05:30
profiles.hh Build a minimized Nix with MinGW 2024-04-17 12:26:10 -04:00
realisation.cc Signer infrastructure: Prep for #9076 2024-01-03 16:13:55 -05:00
realisation.hh Signer infrastructure: Prep for #9076 2024-01-03 16:13:55 -05:00
remote-fs-accessor.cc Build a minimized Nix with MinGW 2024-04-17 12:26:10 -04:00
remote-fs-accessor.hh Merge FSAccessor into SourceAccessor 2023-11-01 17:09:28 +01:00
remote-store-connection.hh Split up util.{hh,cc} 2023-11-05 12:20:02 -05:00
remote-store.cc Fix gcc 12 warnings 2024-02-28 22:59:20 +01:00
remote-store.hh Avoid creating temporary store object for git over the wire 2024-02-27 11:27:34 -05:00
s3-binary-cache-store.cc Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
s3-binary-cache-store.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
s3-binary-cache-store.md Merge how-to section on S3 buckets into S3 store docs (#7972) 2023-10-23 13:22:33 -04:00
s3.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
schema.sql Build the local store on Windows 2024-05-10 13:05:23 -04:00
serve-protocol-impl.cc Query path infos (plural) and handshake version minimum for hydra 2024-05-20 17:43:18 -04:00
serve-protocol-impl.hh Query path infos (plural) and handshake version minimum for hydra 2024-05-20 17:43:18 -04:00
serve-protocol.cc Create ServeProto::BuildOptions and a serializer for it 2023-12-09 11:35:13 -05:00
serve-protocol.hh Factor our ServeProto::BasicServerConnection::handshake 2024-01-22 12:43:11 -05:00
sqlite.cc Make SQLite busy back-off logic portable 2024-04-04 12:43:33 -04:00
sqlite.hh Rename hintfmt to HintFmt 2024-02-08 11:58:25 -08:00
ssh-store-config.cc Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
ssh-store-config.hh Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
ssh-store.cc Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
ssh-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
ssh.cc Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
ssh.hh Create CommonSSHStoreConfig::createSSHMaster 2024-05-27 16:12:53 -04:00
store-api.cc Factor out abstract syntax for Store URIs 2024-05-22 09:20:15 -04:00
store-api.hh Worker proto use proper serialiser for BuildMode 2024-05-27 00:22:55 -04:00
store-cast.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
store-dir-config.hh Use SourcePath in more places 2024-05-06 19:05:42 +02:00
store-reference.cc Add StoreReference::render 2024-05-22 09:20:15 -04:00
store-reference.hh Add StoreReference::render 2024-05-22 09:20:15 -04:00
uds-remote-store.cc Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
uds-remote-store.hh Ensure all store types support "real" URIs 2024-05-21 11:56:40 -04:00
uds-remote-store.md Enable the unix:// store on Windows 2024-04-18 16:58:32 -04:00
worker-protocol-impl.hh Restrict some code to StoreDirConfig 2023-11-04 19:05:36 -04:00
worker-protocol.cc Back in enum values for BuildMode serializer 2024-05-27 00:22:55 -04:00
worker-protocol.hh Worker proto use proper serialiser for BuildMode 2024-05-27 00:22:55 -04:00