aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-01-14also cache split regexes, not just match regexespennae
gives about 1% improvement on system eval, a bit less on nix search. # before nix search --no-eval-cache --offline ../nixpkgs hello Time (mean ± σ): 7.419 s ± 0.045 s [User: 6.362 s, System: 0.794 s] Range (min … max): 7.335 s … 7.517 s 20 runs nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.921 s ± 0.023 s [User: 2.626 s, System: 0.210 s] Range (min … max): 2.883 s … 2.957 s 20 runs # after nix search --no-eval-cache --offline ../nixpkgs hello Time (mean ± σ): 7.370 s ± 0.059 s [User: 6.333 s, System: 0.791 s] Range (min … max): 7.286 s … 7.541 s 20 runs nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.891 s ± 0.033 s [User: 2.606 s, System: 0.210 s] Range (min … max): 2.823 s … 2.958 s 20 runs
2022-01-14optimize removeAttrs builtinpennae
use a sorted array of symbols to be removed instead of a set. this saves a lot of memory allocations and slightly speeds up removal.
2022-01-13move strings in derivationStrictpennae
the temporary will be discarded anyway, so we can move out of it and save many small allocations and copies.
2022-01-13avoid string copies in attrNames sort comparisonpennae
symbols can also be cast to string_view, which compares the same but doesn't require a copy of both symbol names on every comparison.
2022-01-13cache more often-used symbols for primopspennae
there's a few symbols in primops we can create once and pick them out of EvalState afterwards instead of creating them every time we need them. this gives almost 1% speedup to an uncached nix search.
2022-01-13use more string_view in utilspennae
there's a couple places that can be easily converted from using strings to using string_views instead. gives a slight (~1%) boost to system eval. # before nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.946 s ± 0.026 s [User: 2.655 s, System: 0.209 s] Range (min … max): 2.905 s … 2.995 s 20 runs # after Time (mean ± σ): 2.928 s ± 0.024 s [User: 2.638 s, System: 0.211 s] Range (min … max): 2.893 s … 2.970 s 20 runs
2022-01-12Merge pull request #5887 from pennae/avoid-streamsThéophane Hufschmitt
avoid std::?stream overhead when it's not helpful
2022-01-12use boost::lexical_cast for string2*pennae
this avoids one copy from `s` into `str`, and possibly another copy needed to construct `s` at the call site. lexical_cast is also more efficient in general.
2022-01-12optimize ExprConcatStrings::evalpennae
constructing an ostringstream for non-string concats (like integer addition) is a small constant cost that we can avoid. for string concats we can keep all the string temporaries we get from coerceToString and concatenate them in one go, which saves a lot of intermediate temporaries and copies in ostringstream. we can also avoid copying the concatenated string again by directly allocating it in GC memory and moving ownership of the concatenated string into the target value. saves about 2% on system eval. before: Benchmark 1: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.837 s ± 0.031 s [User: 2.562 s, System: 0.191 s] Range (min … max): 2.796 s … 2.892 s 20 runs after: Benchmark 1: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.790 s ± 0.035 s [User: 2.532 s, System: 0.187 s] Range (min … max): 2.722 s … 2.836 s 20 runs
2022-01-11Merge pull request #5883 from fzakaria/faridzakaria/check-metaThéophane Hufschmitt
Check for `--meta` before emitting it for `--json`
2022-01-11Merge pull request #5898 from layus/repair-path-linksEelco Dolstra
Make --repair-path also repair corrupt optimised links
2022-01-11Prefer RepairFlag over bool when applicableGuillaume Maudoux
2022-01-11Make --repair-path also repair corrupt optimised linksGuillaume Maudoux
There already existed a smoke test for the link content length, but it appears that there exists some corruptions pernicious enough to replace the file content with zeros, and keeping the same length. --repair-path now goes as far as checking the content of the link, making it true to its name and actually repairing the path for such coruption cases.
2022-01-10Merge branch 'readfile' of https://github.com/abbradar/nixEelco Dolstra
2022-01-10'target' points to 'source'Eelco Dolstra
2022-01-10Merge branch 'recursive-nix-fix' of https://github.com/L-as/nixEelco Dolstra
2022-01-09Add test for readFile keeping contextNikolay Amiantov
2022-01-09builtins.readFile: Propagate path contextNikolay Amiantov
Co-authored-by: Shea Levy <shea@shealevy.com>
2022-01-07dump(): Use emplace()Eelco Dolstra
2022-01-07isInDir() / isDirOrInDir(): Use std::string_viewEelco Dolstra
2022-01-07DerivationGoal::loadDerivation(): Don't use derivationFromPath()Eelco Dolstra
This causes a recursive call to ensurePath(), which is not a good idea.
2022-01-07avoid ostream sentries per json string characterpennae
we don't have to create an ostream sentry object for every character of a JSON string we write. format a bunch of characters and flush them to the stream all at once instead. this doesn't affect small numbers of string characters, but larger numbers of total JSON string characters written gain a lot. at 1MB of total string written we gain almost 30%, at 16MB it's almost a factor of 3x. large numbers of JSON string characters do occur naturally in a nixos system evaluation to generate documentation (though this is now somewhat mitigated by caching the largest part of nixos option docs). benchmarked with hyperfine 'nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) {e})"' --warmup 1 -L e 1,4,256,4096,65536 before: Benchmark 1: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 1)" Time (mean ± σ): 12.5 ms ± 0.2 ms [User: 9.2 ms, System: 4.0 ms] Range (min … max): 11.9 ms … 13.1 ms 223 runs Benchmark 2: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 4)" Time (mean ± σ): 12.5 ms ± 0.2 ms [User: 9.3 ms, System: 3.8 ms] Range (min … max): 11.9 ms … 13.2 ms 220 runs Benchmark 3: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 256)" Time (mean ± σ): 13.2 ms ± 0.3 ms [User: 9.8 ms, System: 4.0 ms] Range (min … max): 12.6 ms … 14.3 ms 205 runs Benchmark 4: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 4096)" Time (mean ± σ): 24.0 ms ± 0.4 ms [User: 19.4 ms, System: 5.2 ms] Range (min … max): 22.7 ms … 25.8 ms 119 runs Benchmark 5: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 65536)" Time (mean ± σ): 196.0 ms ± 3.7 ms [User: 171.2 ms, System: 25.8 ms] Range (min … max): 190.6 ms … 201.5 ms 14 runs after: Benchmark 1: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 1)" Time (mean ± σ): 12.4 ms ± 0.3 ms [User: 9.1 ms, System: 4.0 ms] Range (min … max): 11.7 ms … 13.3 ms 204 runs Benchmark 2: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 4)" Time (mean ± σ): 12.4 ms ± 0.2 ms [User: 9.2 ms, System: 3.9 ms] Range (min … max): 11.8 ms … 13.0 ms 214 runs Benchmark 3: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 256)" Time (mean ± σ): 12.6 ms ± 0.2 ms [User: 9.5 ms, System: 3.8 ms] Range (min … max): 12.1 ms … 13.3 ms 209 runs Benchmark 4: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 4096)" Time (mean ± σ): 15.9 ms ± 0.2 ms [User: 11.4 ms, System: 5.1 ms] Range (min … max): 15.2 ms … 16.4 ms 171 runs Benchmark 5: nix eval --raw --expr "let s = __concatStringsSep \"\" (__genList (_: \"c\") 256); in __toJSON (__genList (_: s) 65536)" Time (mean ± σ): 69.0 ms ± 0.9 ms [User: 44.3 ms, System: 25.3 ms] Range (min … max): 67.2 ms … 70.9 ms 42 runs
2022-01-06Check for `--meta` before emitting it for `--json`Farid Zakaria
Check that the meta flag is present when emitting JSON query information for `nix-env`. fixes #5882
2022-01-06Merge branch 'install-nlohmann-json-headers' of ↵Eelco Dolstra
https://github.com/hercules-ci/nix
2022-01-06Merge pull request #5878 from fzakaria/faridzakaria/json-outputsEelco Dolstra
Add outputs to JSON query
2022-01-06Merge pull request #5546 from NixOS/allow-paths-in-flake-local-optionsEelco Dolstra
allow paths in flake local options
2022-01-06Add outputs to JSON queryFarid Zakaria
Emit output information when printing JSON information and `--out-paths` is requested. fixes #5877
2022-01-06Merge pull request #5749 from GavinRay97/patch-1Domen Kožar
Better diagnostics if no valid signature found
2022-01-05Merge pull request #5864 from edolstra/attr-sets-cleanupEelco Dolstra
Attrset improvements
2022-01-04Remove EvalState::mkAttrs()Eelco Dolstra
2022-01-04Move empty attrset optimisationEelco Dolstra
2022-01-04Turn mkString(Symbol) into a methodEelco Dolstra
2022-01-04Remove non-method mkPath()Eelco Dolstra
2022-01-04Remove non-method mk<X> functionsEelco Dolstra
2022-01-04Remove non-method mkString()Eelco Dolstra
2022-01-04Ensure that attrsets are sortedEelco Dolstra
Previously you had to remember to call value->attrs->sort() after populating value->attrs. Now there is a BindingsBuilder helper that wraps Bindings and ensures that sort() is called before you can use it.
2022-01-04Merge pull request #5862 from SuperSandro2000/patch-1Eelco Dolstra
Add iana-etc for /etc/protocols to default packages
2022-01-04Add iana-etc for /etc/protocols to default packagesSandro
2022-01-04Merge pull request #5830 from pennae/zipAttrsWithEelco Dolstra
add zipAttrsWith primop
2022-01-03add zipAttrsWith primoppennae
nixpkgs can save a good bit of eval memory with this primop. zipAttrsWith is used quite a bit around nixpkgs (eg in the form of recursiveUpdate), but the most costly application for this primop is in the module system. it improves the implementation of zipAttrsWith from nixpkgs by not checking an attribute multiple times if it occurs more than once in the input list, allocates less values and set elements, and just avoids many a temporary object in general. nixpkgs has a more generic version of this operation, zipAttrsWithNames, but this version is only used once so isn't suitable for being the base of a new primop. if it were to be used more we should add a second primop instead.
2022-01-03Merge pull request #5839 from tweag/balsoft/yet-another-follows-bugfixEelco Dolstra
flake.cc: computeLocks: Only verify overrides when they could change
2022-01-03Merge pull request #5840 from tweag/balsoft/nix-repl-show-traceEelco Dolstra
nix repl: fix --show-trace and add the ability to set trace display
2022-01-03Merge pull request #5844 from Kha/fix-ifd-chroot-once-moreEelco Dolstra
Fix IFD with chroot store
2022-01-03Merge pull request #5852 from autc04/docker-tmp-permissionsEelco Dolstra
docker.nix: set correct permissions on /tmp (fix #5851)
2022-01-01docker.nix: set correct permissions on /tmpWolfgang Thaller
2021-12-29Fix IFD with chroot storeSebastian Ullrich
2021-12-29Add ability to toggle show-trace from within the replAlexander Bantyev
2021-12-29Merge pull request #5841 from lilyinstarlight/fix-fromtoml-attrsEelco Dolstra
Sort attrs from tables in fromTOML
2021-12-28Sort attrs from tables in fromTOMLLily Foster
This was dropped in 10a8b5d for the migration from cpptoml to toml11 but seems to be necessary for the attrsets to work correctly. Fixes #5833
2021-12-28Add a test that nix repl --show-trace actually shows the traceAlexander Bantyev