about summary refs log tree commit diff
path: root/src/libexpr/eval.cc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2013-09-03 nix-env: Load files in ~/.nix-defexpr on demandEelco Dolstra1-0/+6
So if you do "nix-env -qa -A nixos", then other channels won't be parsed/evaluated at all.
2013-09-03 Get rid of the parse tree cacheEelco Dolstra1-13/+17
Since we already cache files in normal form (fileEvalCache), caching parse trees is redundant. Note that getting rid of this cache doesn't actually save much memory at the moment, because parse trees are currently not freed / GC'ed.
2013-09-02 Add some support code for nix-replEelco Dolstra1-1/+8
2013-09-02 Fix whitespaceEelco Dolstra1-22/+22
2013-08-26 Simplify inherited attribute handlingShea Levy1-26/+14
This reduces the difference between inherited and non-inherited attribute handling to the choice of which env to use (in recs and lets) by setting the AttrDef::e to a new ExprVar in the parser rather than carrying a separate AttrDef::v VarRef member. As an added bonus, this allows inherited attributes that inherit from a with to delay forcing evaluation of the with's attributes. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-08-26 Fix typos, especially those that end up in the Nix manualIvan Kozik1-1/+1
2013-08-19 Store Nix integers as longsEelco Dolstra1-2/+2
So on 64-bit systems, integers are now 64-bit. Fixes #158.
2013-08-02 In the profiler output, show function names (if available)Eelco Dolstra1-7/+7
2013-08-02 Overload the ‘+’ operator to support integer additionEelco Dolstra1-11/+19
2013-07-31 Make Env smallerEelco Dolstra1-19/+21
Commit 20866a7031ca823055a221653b77986faa167329 added a ‘withAttrs’ field to Env, which is annoying because it makes every Env structure bigger and we allocate millions of them. E.g. NixOS evaluation took 18 MiB more. So this commit squeezes ‘withAttrs’ into values[0]. Probably should use a union...
2013-07-31 Don't use NULLEelco Dolstra1-4/+2
2013-07-31 Avoid thunks when a fromWith var can be looked up without evaluationShea Levy1-7/+7
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-07-31 Delay evaulation of `with` attrs until a variable lookup needs themShea Levy1-7/+12
Evaluation of attribute sets is strict in the attribute names, which means immediate evaluation of `with` attribute sets rules out some potentially interesting use cases (e.g. where the attribute names of one set depend in some way on another but we want to bring those names into scope for some values in the second set). The major example of this is overridable self-referential package sets (e.g. all-packages.nix). With immediate `with` evaluation, the only options for such sets are to either make them non-recursive and explicitly use the name of the overridden set in non-overridden one every time you want to reference another package, or make the set recursive and use the `__overrides` hack. As shown in the test case that comes with this commit, though, delayed `with` evaluation allows a nicer third alternative. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-05-16 Show function names in error messagesEelco Dolstra1-4/+9
Functions in Nix are anonymous, but if they're assigned to a variable/attribute, we can use the variable/attribute name in error messages, e.g. while evaluating `concatMapStrings' at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/strings.nix:18:25': ...
2013-05-16 Show which function argument was unexpectedEelco Dolstra1-5/+9
Fixes #116.
2013-05-16 Shut up a compiler warningEelco Dolstra1-1/+1
2013-03-08 Revert "Prevent config.h from being clobbered"Eelco Dolstra1-1/+1
This reverts commit 28bba8c44f484eae38e8a15dcec73cfa999156f6.
2013-03-07 Prevent config.h from being clobberedEelco Dolstra1-1/+1
2013-02-08 Make "${./path} ..." evaluate to a string, not a pathEelco Dolstra1-1/+1
Wacky string coercion semantics caused expressions like exec = "${./my-script} params..."; to evaluate to a path (‘/path/my-script params’), because anti-quotations are desuged to string concatenation: exec = ./my-script + " params..."; By constrast, adding a space at the start would yield a string as expected: exec = " ${./my-script} params..."; Now the first example also evaluates to a string.
2012-11-28 nix-env -q --out-path: Support multiple outputsEelco Dolstra1-0/+1
We now print all output paths of a package, e.g. openssl-1.0.0i bin=/nix/store/gq2mvh0wb9l90djvsagln3aqywqmr6vl-openssl-1.0.0i-bin;man=/nix/store/7zwf5r5hsdarl3n86dasvb4chm2xzw9n-openssl-1.0.0i-man;/nix/store/cj7xvk7fjp9q887359j75pw3pzjfmqf1-openssl-1.0.0i or (in XML mode) <item attrPath="openssl" name="openssl-1.0.0i" system="x86_64-linux"> <output name="bin" path="/nix/store/gq2mvh0wb9l90djvsagln3aqywqmr6vl-openssl-1.0.0i-bin" /> <output name="man" path="/nix/store/7zwf5r5hsdarl3n86dasvb4chm2xzw9n-openssl-1.0.0i-man" /> <output name="out" path="/nix/store/cj7xvk7fjp9q887359j75pw3pzjfmqf1-openssl-1.0.0i" /> </item>
2012-11-27 Optionally ignore null-valued derivation attributesEelco Dolstra1-0/+1
This allows adding attributes like attr = if stdenv.system == "bla" then something else null; without changing the resulting derivation on non-<bla> platforms. We once considered adding a special "ignore" value for this purpose, but using null seems more elegant.
2012-11-26 nix-instantiate: Fix read-only evaluationEelco Dolstra1-0/+1
2012-11-09 Fix a segfault when auto-calling a "a@{...}" functionEelco Dolstra1-5/+5
Since the called function can return its argument attribute set (e.g. "a"), the latter should not be allocated on the stack. Reported by Shea.
2012-10-03 Add a ‘--repair’ flag to nix-instantiateEelco Dolstra1-1/+2
This allows repairing corrupted derivations and other source files.
2012-09-19 Templatise tokenizeString()Eelco Dolstra1-1/+1
2012-08-27 Merge branch 'master' into no-manifestsEelco Dolstra1-11/+75
2012-08-13 Avoid concatenating lists of one stringEelco Dolstra1-1/+1
2012-08-13 Don't allocate empty listsEelco Dolstra1-1/+1
This saves about 4 MB when evaluating a NixOS system configuration.
2012-08-13 Optimise concatenating a list to an empty listEelco Dolstra1-2/+10
More precisely, in concatLists, if all lists except one are empty, then just return the non-empty list. This reduces the number of list element allocations by 32% when evaluating a NixOS system configuration.
2012-08-13 Add a primop ‘concatLists’Eelco Dolstra1-8/+21
This can serve as a generic efficient list builder. For instance, the function ‘catAttrs’ in Nixpkgs can be rewritten from attr: l: fold (s: l: if hasAttr attr s then [(getAttr attr s)] ++ l else l) [] l to attr: l: builtins.concatLists (map (s: if hasAttr attr s then [(getAttr attr s)] else []) l) Statistics before: time elapsed: 1.08683 size of a value: 24 environments allocated: 1384376 (35809568 bytes) list elements: 6946783 (55574264 bytes) list concatenations: 37434 values allocated: 1760440 (42250560 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18273 number of thunks: 1297673 number of thunks avoided: 1380759 number of attr lookups: 430802 number of primop calls: 628912 number of function calls: 1333544 Statistics after (including new catAttrs): time elapsed: 0.959854 size of a value: 24 environments allocated: 1010198 (26829296 bytes) list elements: 1984878 (15879024 bytes) list concatenations: 30488 values allocated: 1589760 (38154240 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18274 number of thunks: 1040925 number of thunks avoided: 1038428 number of attr lookups: 438419 number of primop calls: 474844 number of function calls: 959366
2012-08-13 Add a "filter" primopEelco Dolstra1-1/+1
Evaluation of a NixOS configuration spends quite a lot of time in the "filter" function in Nixpkgs. As implemented in Nixpkgs, this is a O(n^2) operation, so it's a good candidate for providing a more efficient (i.e. primop) implementation. Using it gives a ~10% speed increase and a significant reduction in the number of evaluations. Statistics before (on a NixOS system config): time elapsed: 1.3258 size of a value: 24 environments allocated: 1980939 (50127080 bytes) list elements: 14679308 (117434464 bytes) list concatenations: 50828 values allocated: 2098938 (50374512 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18271 number of thunks: 1645752 number of thunks avoided: 1921196 number of attr lookups: 430798 number of primop calls: 838807 number of function calls: 1930107 Statistics after: time elapsed: 1.17982 size of a value: 24 environments allocated: 1543334 (39624560 bytes) list elements: 9612638 (76901104 bytes) list concatenations: 37434 values allocated: 1854933 (44518392 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18272 number of thunks: 1392467 number of thunks avoided: 1507311 number of attr lookups: 430801 number of primop calls: 691600 number of function calls: 1492502
2012-08-12 Add some more evaluations statsEelco Dolstra1-0/+7
2012-08-12 Add some basic profiling support to the evaluatorEelco Dolstra1-1/+37
Setting the environment variable NIX_COUNT_CALLS to 1 enables some basic profiling in the evaluator. It will count calls to functions and primops as well as evaluations of attributes. For example, to see where evaluation of a NixOS configuration spends its time: $ NIX_SHOW_STATS=1 NIX_COUNT_CALLS=1 ./src/nix-instantiate/nix-instantiate '<nixos>' -A system --readonly-mode ... calls to 39 primops: 239532 head 233962 tail 191252 hasAttr ... calls to 1595 functions: 224157 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:19' 221767 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:14' 221767 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/lists.nix:17:10' ... evaluations of 7088 attributes: 167377 undefined position 132459 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/attrsets.nix:119:41' 47322 `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/attrsets.nix:13:21' ...
2012-07-30 Refactor settings processingEelco Dolstra1-2/+2
Put all Nix configuration flags in a Settings object.
2012-07-17 Remove dead codeEelco Dolstra1-9/+0
2012-02-04 * Inline some functions and get rid of the indirection throughEelco Dolstra1-108/+23
EvalState::eval(). This gives a 12% speedup on ‘nix-instantiate /etc/nixos/nixos/ -A system --readonly-mode’ (from 1.01s to 0.89s).
2012-02-04 * Print elapsed evaluation time.Eelco Dolstra1-1/+9
2012-01-19 * Allow comparisons between derivations by comparing the outPathEelco Dolstra1-2/+14
attributes.
2012-01-07 * Don't create thunks for simple constants (integers, strings, paths)Eelco Dolstra1-18/+26
and allocate them only once. * Move Value and related functions into value.hh.
2012-01-04 * Remove dead code.Eelco Dolstra1-2/+0
2012-01-04 * Don't use dynamic_cast, it's very slow. "nix-instantiateEelco Dolstra1-22/+21
/etc/nixos/nixos -A system" spent about 10% of its time in dynamic_cast.
2012-01-03 * Move the implementation of the ‘derivation’ primop into a separateEelco Dolstra1-2/+2
file.
2011-11-06 Remove the unused sCurrentOutput symbolShea Levy1-1/+0
2011-11-06 Merge from trunkShea Levy1-3/+6
2011-10-27 * In printValueAsXML, handle the case where a "type" attribute is notEelco Dolstra1-3/+6
a string. This happens in the NixOS option system. * Remove a bogus comparison of a unsigned integer with -1.
2011-09-16 Add an sCurrentOutput member to EvalStateShea Levy1-0/+1
2011-08-06 * Cache the result of file evaluation (i.e, memoize evalFile()). ThisEelco Dolstra1-11/+13
prevents files from being evaluated and stored as values multiple times. For instance, evaluation of the ‘system’ attribute in NixOS causes ‘nixpkgs/pkgs/lib/lists.nix’ to be evaluated 2019 times. Caching gives a modest speedup and a decent memory footprint reduction (e.g., from 1.44s to 1.28s, and from 81 MiB to 59 MiB with GC_INITIAL_HEAP_SIZE=100000 on my system).
2011-08-06 * Remove a debug statement.Eelco Dolstra1-1/+0
2011-08-06 * Add the Nix corepkgs to the end of the search path. This makes itEelco Dolstra1-0/+2
possible for other Nix expressions to use corepkgs (mostly useful for the buildenv function).
2011-08-06 * Add a Nix expression search path feature. Paths between angleEelco Dolstra1-0/+6
brackets, e.g. import <nixpkgs/pkgs/lib> are resolved by looking them up relative to the elements listed in the search path. This allows us to get rid of hacks like import "${builtins.getEnv "NIXPKGS_ALL"}/pkgs/lib" The search path can be specified through the ‘-I’ command-line flag and through the colon-separated ‘NIX_PATH’ environment variable, e.g., $ nix-build -I /etc/nixos ... If a file is not found in the search path, an error message is lazily thrown.