Ben Burdette
3dfab6e534
have only one debuggerHook declaration
2022-03-14 11:58:11 -06:00
Ben Burdette
eaecaaa00b
more debug_throw coverage of EvalErrors
2022-03-14 11:39:53 -06:00
John Ericson
91adfb8894
Create some type aliases for string Contexts
2022-03-11 22:30:10 +00:00
John Ericson
0948b8e94d
Reduce variants for derivation hash modulo
...
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-03-11 21:20:37 +00:00
Eelco Dolstra
aee56e0f89
Merge remote-tracking branch 'origin/eval-suggestions'
2022-03-11 12:02:26 +01:00
Eelco Dolstra
31a392dfe2
Merge pull request #5865 from pennae/memory-friendliness
...
be more memory friendly
2022-03-11 11:52:39 +01:00
John Ericson
938650700f
Merge branch 'path-info' into ca-drv-exotic
2022-03-10 16:20:01 +00:00
John Ericson
8ba089597f
Merge remote-tracking branch 'upstream/master' into path-info
2022-03-10 15:48:14 +00:00
pennae
4d629c4f7a
add HAVE_BOEHMGC guards to batched allocation functions
2022-03-09 00:18:50 +01:00
pennae
47baa9d43c
make Pos smaller
...
reduces peak hep memory use on eval of our test system from 264.4MB to 242.3MB,
possibly also a slight performance boost.
theoretically memory use could be cut down by another eight bytes per Pos on
average by turning it into a tuple containing an index into a global base
position table with row and column offsets, but that doesn't seem worth the
effort at this point.
2022-03-08 23:30:18 +01:00
pennae
c96460f352
force-inline a few much-used functions
...
these functions are called a whole lot, and they're all comparatively small.
always inlining them gives ~0.7% performance boost on eval.
before:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.935 s ± 0.052 s [User: 5.852 s, System: 0.853 s]
Range (min … max): 6.808 s … 7.026 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 329.8 ms ± 2.7 ms [User: 299.0 ms, System: 30.8 ms]
Range (min … max): 326.6 ms … 336.5 ms 20 runs
Benchmark 3: nix flakes eval --raw --impure --file expr.nix
Time (mean ± σ): 2.655 s ± 0.038 s [User: 2.364 s, System: 0.220 s]
Range (min … max): 2.574 s … 2.737 s 20 runs
after:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.912 s ± 0.036 s [User: 5.823 s, System: 0.856 s]
Range (min … max): 6.849 s … 6.980 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 325.1 ms ± 2.5 ms [User: 293.2 ms, System: 31.8 ms]
Range (min … max): 322.2 ms … 332.8 ms 20 runs
Benchmark 3: nix flakes eval --raw --impure --file expr.nix
Time (mean ± σ): 2.636 s ± 0.024 s [User: 2.352 s, System: 0.226 s]
Range (min … max): 2.574 s … 2.681 s 20 runs
2022-03-08 23:30:18 +01:00
pennae
60ed4e908a
cache singleton Envs just like Values
...
vast majority of envs is this size.
before:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.946 s ± 0.041 s [User: 5.875 s, System: 0.835 s]
Range (min … max): 6.834 s … 7.005 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 330.3 ms ± 2.5 ms [User: 299.2 ms, System: 30.9 ms]
Range (min … max): 327.5 ms … 337.7 ms 20 runs
Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'
Time (mean ± σ): 2.671 s ± 0.035 s [User: 2.370 s, System: 0.232 s]
Range (min … max): 2.597 s … 2.749 s 20 runs
after:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.935 s ± 0.052 s [User: 5.852 s, System: 0.853 s]
Range (min … max): 6.808 s … 7.026 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 329.8 ms ± 2.7 ms [User: 299.0 ms, System: 30.8 ms]
Range (min … max): 326.6 ms … 336.5 ms 20 runs
Benchmark 3: nix flakes eval --raw --impure --file expr.nix
Time (mean ± σ): 2.655 s ± 0.038 s [User: 2.364 s, System: 0.220 s]
Range (min … max): 2.574 s … 2.737 s 20 runs
2022-03-08 23:30:18 +01:00
pennae
4b2b0d3a55
remove GC_PTR_STORE_AND_DIRTY
...
turns out it's only necessary for MANUAL_VDB, which nix doesn't use. omitting
them gives a slight performance improvement on eval.
before:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.988 s ± 0.061 s [User: 5.935 s, System: 0.845 s]
Range (min … max): 6.865 s … 7.075 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 332.6 ms ± 3.9 ms [User: 299.6 ms, System: 32.9 ms]
Range (min … max): 328.1 ms … 339.1 ms 20 runs
Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'
Time (mean ± σ): 2.681 s ± 0.049 s [User: 2.382 s, System: 0.228 s]
Range (min … max): 2.607 s … 2.776 s 20 runs
after:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.946 s ± 0.041 s [User: 5.875 s, System: 0.835 s]
Range (min … max): 6.834 s … 7.005 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 330.3 ms ± 2.5 ms [User: 299.2 ms, System: 30.9 ms]
Range (min … max): 327.5 ms … 337.7 ms 20 runs
Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'
Time (mean ± σ): 2.671 s ± 0.035 s [User: 2.370 s, System: 0.232 s]
Range (min … max): 2.597 s … 2.749 s 20 runs
2022-03-08 23:30:18 +01:00
regnat
f6078e474d
Also display some suggestions for invalid formal arguments
...
```console
$ nix eval --expr '({ foo ? 1 }: foo) { fob = 2; }'
error: anonymous function at (string):1:2 called with unexpected argument 'fob'
at «string»:1:1:
1| ({ foo ? 1 }: foo) { fob = 2; }
| ^
Did you mean foo?
```
Not that because Nix will first check for _missing_ arguments before
checking for extra arguments, `({ foo }: foo) { fob = 1; }` will
complain about the missing `foo` argument (rather than extra `fob`) and
so won’t display a suggestion.
2022-03-08 16:40:22 +01:00
regnat
33b7514035
Try and make the darwin build happy
2022-03-08 16:07:17 +01:00
regnat
0c6e46e349
Add some suggestions to the evaluator
...
Make the evaluator show some suggestions when trying to access an
invalid field from an attrset.
```console
$ nix eval --expr '{ foo = 1; }.foa'
error: attribute 'foa' missing
at «string»:1:1:
1| { foo = 1; }.foa
| ^
Did you mean foo?
```
2022-03-08 06:21:45 +01:00
Eelco Dolstra
30ddd37873
Merge branch 'cli-suggestions' of https://github.com/thufschmitt/nix
2022-03-07 19:47:45 +01:00
regnat
dcf4f77fac
Merge or-suggestions.hh into suggestions.hh
...
No real need for keeping a separate header for such a simple class.
This requires changing a bit `OrSuggestions<T>::operator*` to not throw
an `Error` to prevent a cyclic dependency. But since this error is only
thrown on programmer error, we can replace the whole method by a direct
call to `std::get` which will raise its own assertion if needs be.
2022-03-07 17:49:02 +01:00
Robert Hensing
da260f579d
dupStringWithLen -> makeImmutableString
...
Refactor the `size == 0` logic into a new helper function that
replaces dupStringWithLen.
The name had to change, because unlike a `dup`-function, it does
not always allocate a new string.
2022-03-07 16:09:12 +01:00
Robert Hensing
bbf55383e7
Value::mkPath: Avoid potential crash from null string_view
2022-03-07 16:09:12 +01:00
Robert Hensing
1b978596b5
Value::mkString: Avoid crash from null string_view
2022-03-07 16:09:12 +01:00
Naïm Favier
da7d8daa77
Add shell completion for --override-flake
...
Requires moving the MixEvalArgs class from libexpr to libcmd because
that's where completeFlakeRef is.
2022-03-07 12:01:54 +01:00
Guillaume Maudoux
13c4dc6532
more fixes
2022-03-07 11:33:03 +01:00
regnat
fd45d85b41
Move OrSuggestions to its own header
...
Prevents a recursive inclusion
2022-03-07 10:09:10 +01:00
regnat
98e361ad4c
Also display suggestions for the commands using the eval cache
...
Make `nix build .#nix-armv8l-linux` work for example
2022-03-07 10:09:10 +01:00
regnat
c0792b1546
Implement a suggestions mechanism
...
Each `Error` class now includes a set of suggestions, and these are printed by
the top-level handler.
2022-03-07 10:09:09 +01:00
Guillaume Maudoux
1b5a8db148
change error location for genericClosure operator errors
2022-03-05 21:19:04 +01:00
Guillaume Maudoux
4078015927
DRY addPrimOp
2022-03-05 21:18:30 +01:00
Guillaume Maudoux
cbbbf36881
Use 'errorCtx' name everywhere
2022-03-04 22:55:14 +01:00
Guillaume Maudoux
57684d6247
fixup! s/forceValue/forceFunction/ where applicable
2022-03-04 22:51:56 +01:00
Guillaume Maudoux
ed02fa3c40
s/forceValue/forceFunction/ where applicable
2022-03-04 22:15:30 +01:00
Guillaume Maudoux
3a5855353e
Add detailed error mesage for coerceTo{String,Path}
2022-03-04 21:47:58 +01:00
Guillaume Maudoux
be1f069746
Add error context for most basic coercions
2022-03-04 05:04:47 +01:00
Guillaume Maudoux
00e242feed
Add some context to coercion error strings
2022-03-03 21:46:20 +01:00
Eelco Dolstra
e9c04c3351
Be more aggressive in hiding repeated values
...
We now memoize on Bindings / list element vectors rather than Values,
so that e.g. two Values that point to the same Bindings will be
printed only once.
2022-03-03 13:33:34 +01:00
Eelco Dolstra
ecff9d969a
printValue(): Don't show repeated values
...
Fixes #6157 .
2022-03-03 13:18:23 +01:00
Eelco Dolstra
6097790863
Fix segfault in headerCallback()
...
https://hydra.nixos.org/build/168594664
2022-03-03 11:11:16 +01:00
Eelco Dolstra
b55d79728c
Add EvalState::coerceToStorePath() helper
...
This is useful whenever we want to evaluate something to a store path
(e.g. in get-drvs.cc).
Extracted from the lazy-trees branch (where we can require that a
store path must come from a store source tree accessor).
2022-03-02 23:58:58 +01:00
Eelco Dolstra
0cb5af5000
Merge pull request #6185 from hercules-ci/fetchTree-reuse-local-paths
...
fetchTree: Use isValidPath, add comment
2022-03-01 13:15:42 +01:00
Robert Hensing
b6deca7c0d
fetchTree: Use isValidPath, add comment
2022-03-01 12:11:10 +01:00
Eelco Dolstra
d974d2ad59
fetch{url,Tarball}: Remove 'narHash' attribute
...
This was introduced in #6174 . However fetch{url,Tarball} are legacy
and we shouldn't have an undocumented attribute that does the same
thing as one that already exists ('sha256').
2022-03-01 11:30:26 +01:00
Eelco Dolstra
9ab81a9d38
Merge pull request #6183 from obsidiansystems/sort-config
...
Move some stuff from `Settings` to a new `FetchSettings`.
2022-03-01 10:52:55 +01:00
John Ericson
ea71da395f
Move some stuff from Settings to a new FetchSettings.
...
Starting work on #5638
The exact boundary between `FetchSettings` and `EvalSettings` is not
clear to me, but that's fine. First lets clean out `libstore`, and then
worry about what, if anything, should be the separation between those
two.
2022-03-01 01:39:25 +00:00
Robert Hensing
ee019d0afc
Add EvalState::allowAndSetStorePathString helper
...
This switches addPath from `printStorePath` to `toRealPath`.
2022-02-28 21:37:49 +01:00
Robert Hensing
158280d8e9
fetchTree: Do not re-fetch paths already present
2022-02-28 21:37:49 +01:00
Eelco Dolstra
df552ff53e
Remove std::string alias (for real this time)
...
Also use std::string_view in a few more places.
2022-02-25 16:13:02 +01:00
Eelco Dolstra
9d4697453f
ExprAttrs::show(): Show attrs in sorted order
...
Issue #6160 .
2022-02-25 09:21:04 +01:00
Eelco Dolstra
8518cebfce
libfetchers: Rename immutable -> locked
...
This is more consistent with flake terminology.
2022-02-24 18:09:00 +01:00
Eelco Dolstra
36c7b12f33
Remove std::string alias
2022-02-21 16:37:25 +01:00
Eelco Dolstra
1ac2664472
Remove std::vector alias
2022-02-21 16:32:34 +01:00