aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
AgeCommit message (Collapse)Author
2022-03-18Generalize `DerivationType` in preparation for impure derivationsJohn Ericson
2022-03-18Avoid some pointless copying of drvsJohn Ericson
2022-03-18Use Deferred when building an input-addressed drvJohn Ericson
Easier than using dummy path with input addressed.
2022-03-17Clean up `DerivationOutput`, and headersJohn Ericson
1. `DerivationOutput` now as the `std::variant` as a base class. And the variants are given hierarchical names under `DerivationOutput`. In 8e0d0689be797f9e42f9b43b06f50c1af7f20b4a @matthewbauer and I didn't know a better idiom, and so we made it a field. But this sort of "newtype" is anoying for literals downstream. Since then we leaned the base class, inherit the constructors trick, e.g. used in `DerivedPath`. Switching to use that makes this more ergonomic, and consistent. 2. `store-api.hh` and `derivations.hh` are now independent. In bcde5456cc3295061a0726881c3e441444dd6680 I swapped the dependency, but I now know it is better to just keep on using incomplete types as much as possible for faster compilation and good separation of concerns.
2022-03-16formattingBen Burdette
2022-03-14more debug_throw coverage of EvalErrorsBen Burdette
2022-03-11Reduce variants for derivation hash moduloJohn Ericson
This changes was taken from dynamic derivation (#4628). It` somewhat undoes the refactors I first did for floating CA derivations, as the benefit of hindsight + requirements of dynamic derivations made me reconsider some things. They aren't to consequential, but I figured they might be good to land first, before the more profound changes @thufschmitt has in the works.
2022-02-28Add EvalState::allowAndSetStorePathString helperRobert Hensing
This switches addPath from `printStorePath` to `toRealPath`.
2022-02-25Remove std::string alias (for real this time)Eelco Dolstra
Also use std::string_view in a few more places.
2022-02-21Remove std::vector aliasEelco Dolstra
2022-02-21Remove std::set aliasEelco Dolstra
2022-02-21Remove std::list aliasEelco Dolstra
2022-02-15quit repl from step modeBen Burdette
2022-02-14make an 'info' level error on breakBen Burdette
2022-02-11for primops, enter the debugger at the last DebugTrace in the stackBen Burdette
2022-02-04Merge branch 'master' into debug-stepBen Burdette
2022-02-04print value in breakBen Burdette
2022-02-04Merge branch 'issue-3505' of https://github.com/kamadorueda/nixEelco Dolstra
2022-02-03break() primop; step and go debug commandsBen Burdette
2022-02-02Merge branch 'more-stringviews' of https://github.com/pennae/nixEelco Dolstra
2022-01-30fix spelling mistakes reported by Debian's lintian toolThomas Koch
2022-01-28Remove a repeated std::move in a for loopEelco Dolstra
2022-01-27optionally return string_view from coerceToStringpennae
we'll retain the old coerceToString interface that returns a string, but callers that don't need the returned value to outlive the Value it came from can save copies by using the new interface instead. for values that weren't stringy we'll pass a new buffer argument that'll be used for storage and shouldn't be inspected.
2022-01-27return string_views from forceString*pennae
once a string has been forced we already have dynamic storage allocated for it, so we can easily reuse that storage instead of copying.
2022-01-27Don’t require `NIX_PATH` entries to be valid pathsregnat
It’s totally valid to have entries in `NIX_PATH` that aren’t valid paths (they can even be arbitrary urls or `channel:<channel-name>`). Fix #5998 and #5980
2022-01-24Allow builtins.{readFile,path} on invalid pathsEelco Dolstra
Stop-gap measure to fix #5975.
2022-01-21forceAttrs: make pos mandatoryKevin Amado
2022-01-21Fix exception handling around realisePath()Eelco Dolstra
This no longer worked correctly because 'path' is uninitialised when an exception occurs, leading to errors like … while importing '' at /nix/store/rrzz5b1pshvzh1437ac9nkl06br81lkv-source/flake.nix:352:13: So move the adding of the error context into realisePath().
2022-01-18Merge pull request #5906 from pennae/primops-optimizationEelco Dolstra
optimize primops and utils by caching more and copying less
2022-01-17Merge pull request #5812 from pennae/small-perf-improvementsEelco Dolstra
improve parser performance a bit
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-13avoid copies of parser input datapennae
when given a string yacc will copy the entire input to a newly allocated location so that it can add a second terminating NUL byte. since the parser is a very internal thing to EvalState we can ensure that having two terminating NUL bytes is always possible without copying, and have the parser itself merely check that the expected NULs are present. # before Benchmark 1: nix search --offline nixpkgs hello Time (mean ± σ): 572.4 ms ± 2.3 ms [User: 563.4 ms, System: 8.6 ms] Range (min … max): 566.9 ms … 579.1 ms 50 runs Benchmark 2: nix eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix Time (mean ± σ): 381.7 ms ± 1.0 ms [User: 348.3 ms, System: 33.1 ms] Range (min … max): 380.2 ms … 387.7 ms 50 runs Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.936 s ± 0.005 s [User: 2.715 s, System: 0.221 s] Range (min … max): 2.923 s … 2.946 s 50 runs # after Benchmark 1: nix search --offline nixpkgs hello Time (mean ± σ): 571.7 ms ± 2.4 ms [User: 563.3 ms, System: 8.0 ms] Range (min … max): 566.7 ms … 579.7 ms 50 runs Benchmark 2: nix eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix Time (mean ± σ): 376.6 ms ± 1.0 ms [User: 345.8 ms, System: 30.5 ms] Range (min … max): 374.5 ms … 379.1 ms 50 runs Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.922 s ± 0.006 s [User: 2.707 s, System: 0.215 s] Range (min … max): 2.906 s … 2.934 s 50 runs
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-09builtins.readFile: Propagate path contextNikolay Amiantov
Co-authored-by: Shea Levy <shea@shealevy.com>
2022-01-04Remove EvalState::mkAttrs()Eelco 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-03Merge branch 'master' into debug-exploratory-PRBen Burdette
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.
2021-12-29Fix IFD with chroot storeSebastian Ullrich
2021-12-23Properly return false on `builtins.pathExists /someNonAllowedPath`regnat
Follow-up from https://github.com/NixOS/nix/pull/5807 to fix https://github.com/NixOS/nix/pull/5807#issuecomment-1000135394
2021-12-21Fix IFD with CA derivationsregnat
Rewrite the string taken by the IFD-like primops to contain the actual output paths of the derivations rather than the placeholders Fix #5805
2021-12-21Factor out the path realisation bit of IFDregnat
2021-12-02Introduce builtins.groupBy primopSilvan Mosberger
This function is very useful in nixpkgs, but its implementation in Nix itself is rather slow due to it requiring a lot of attribute set and list appends.