1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-11 13:06:01 +01:00
nix/src/libutil
Sergei Zimmerman 8708e9a526
libutil: Use caching directory_entry API in PosixSourceAccessor::readDirectory
Previous use of symlink_status() always translated into a stat call, leading
to huge performance penalties for by-name-overlay in nixpkgs. The comment
below references the possible caching, but that seemed to be erroneous, since
the correct way to make use of the caching API is by calling a bunch of `is_*`
functions [1]. For example, here's how libstdc++ does that [2], [3].

This translates to great nixpkgs eval performance improvements:

```
Benchmark 1: GC_INITIAL_HEAP_SIZE=4G result/bin/nix-instantiate ../nixpkgs -A hello --readonly-mode
  Time (mean ± σ):     186.7 ms ±   6.7 ms    [User: 121.3 ms, System: 64.9 ms]
  Range (min … max):   179.4 ms … 201.6 ms    16 runs

Benchmark 2: GC_INITIAL_HEAP_SIZE=4G nix-instantiate ../nixpkgs -A hello --readonly-mode
  Time (mean ± σ):     230.6 ms ±   5.0 ms    [User: 126.9 ms, System: 103.1 ms]
  Range (min … max):   225.1 ms … 241.4 ms    13 runs
```

[1]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0317r1.html
[2]: 8ea555b7b4/libstdc%2B%2B-v3/include/bits/fs_dir.h (L341-L348)
[3]: 8ea555b7b4/libstdc%2B%2B-v3/include/bits/fs_dir.h (L161-L163)
2025-06-30 23:29:07 +03:00
..
freebsd Restore multiline formatting of lists in meson files 2025-06-20 23:12:36 +03:00
include/nix/util Replace 'bool sync' with an enum for clarity 2025-06-22 16:48:34 +02:00
linux Restore multiline formatting of lists in meson files 2025-06-20 23:12:36 +03:00
signature Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
unix Fix various typos in source code 2025-05-25 20:14:11 +00:00
widecharwidth try to calculate character width 2024-12-28 12:01:32 +01:00
windows Restore multiline formatting of lists in meson files 2025-06-20 23:12:36 +03:00
.version Build nix-util with Meson 2024-06-12 18:31:02 -04:00
archive.cc Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
args.cc treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
canon-path.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
compression.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
compute-levels.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
config-global.cc Simplify ConfigRegistrations 2025-05-05 09:42:16 +02:00
configuration.cc treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
current-process.cc Prepare for FreeBSD sandboxing support 2025-05-27 14:54:50 -04:00
english.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
environment-variables.cc Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
error.cc libutil: Use std::shared_ptr<const Pos> instead of std::shared_ptr<Pos> 2025-06-01 20:55:26 +00:00
executable-path.cc Drop fs alias in favour of std::filesystem 2025-05-01 14:24:34 +02:00
exit.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
experimental-features.cc Rework future tense in user-facing messages 2025-06-12 09:07:36 -07:00
file-content-address.cc Replace 'bool sync' with an enum for clarity 2025-06-22 16:48:34 +02:00
file-descriptor.cc Drop guessOrInventPathFromFD() 2025-06-22 16:48:34 +02:00
file-system.cc Replace 'bool sync' with an enum for clarity 2025-06-22 16:48:34 +02:00
fs-sink.cc Add -Wundef to make #if FOO an error if not defined 2025-04-05 00:45:19 +02:00
git.cc libutil: Use correct argument to Error format ctor 2025-04-24 22:27:03 +00:00
hash.cc Fix various typos in source code 2025-05-25 20:14:11 +00:00
hilite.cc Fix various typos in source code 2025-05-25 20:14:11 +00:00
json-utils.cc bugfix in getInteger(const nlohmann::json &) and add bounds checks 2025-04-30 01:38:48 +02:00
logging.cc libutil: Use std::shared_ptr<const Pos> instead of std::shared_ptr<Pos> 2025-06-01 20:55:26 +00:00
memory-source-accessor.cc Clear displayPrefix in makeEmptySourceAccessor 2025-05-29 19:35:12 +00:00
meson.build Drop guessOrInventPathFromFD() 2025-06-22 16:48:34 +02:00
meson.options Build nix-util with Meson 2024-06-12 18:31:02 -04:00
mounted-source-accessor.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
nix-meson-build-support rename: build-utils-meson -> nix-meson-build-support 2024-12-09 16:54:42 +01:00
package.nix Fix FreeBSD builds 2025-05-28 12:47:33 -04:00
pos-table.cc libexpr: Actually cache line information in PosTable 2025-05-15 23:07:25 +00:00
position.cc libutil: Use std::shared_ptr<const Pos> instead of std::shared_ptr<Pos> 2025-06-01 20:55:26 +00:00
posix-source-accessor.cc libutil: Use caching directory_entry API in PosixSourceAccessor::readDirectory 2025-06-30 23:29:07 +03:00
references.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
serialise.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
source-accessor.cc cherry-pick https://gerrit.lix.systems/c/lix/+/2100 2025-05-21 08:49:09 -07:00
source-path.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
strings.cc treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
subdir-source-accessor.cc Store::getFSAccessor: Do not include the store dir 2025-04-09 17:34:18 -04:00
suggestions.cc treewide: Use StringSet alias consistently instead of std::set<std::string> 2025-05-02 17:40:29 +00:00
tarfile.cc Merge pull request #13175 from xokdvium/optimise-fetchtarball 2025-05-13 14:21:26 +02:00
tee-logger.cc Add json-log-path setting 2025-05-23 10:45:12 +02:00
terminal.cc libutil: amend OSC 8 escape stripping for xterm-style separator 2025-04-29 16:12:18 +01:00
thread-pool.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
union-source-accessor.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
unix-domain-socket.cc Fix mingw build 2025-05-28 00:48:10 +02:00
url.cc Use StringMap instead of std::map<std::string, std::string> throughout the codebase 2025-05-19 20:33:28 +00:00
users.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00
util.cc Rename shellEscape -> escapeShellArgAlways 2025-04-23 22:56:07 +02:00
xml-writer.cc Expose the nix component in header include paths 2025-04-01 11:40:42 -04:00