about summary refs log tree commit diff
path: root/src/libexpr/eval.hh (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-6/+6
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-7/+8
2013-09-02 Fix whitespaceEelco Dolstra1-10/+10
2013-08-26 Simplify inherited attribute handlingShea Levy1-1/+1
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-19 Store Nix integers as longsEelco Dolstra1-1/+1
So on 64-bit systems, integers are now 64-bit. Fixes #158.
2013-08-14 TypoEelco Dolstra1-1/+1
2013-08-02 In the profiler output, show function names (if available)Eelco Dolstra1-1/+1
2013-07-31 Make Env smallerEelco Dolstra1-2/+2
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 Avoid thunks when a fromWith var can be looked up without evaluationShea Levy1-1/+1
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-07-31 Delay evaulation of `with` attrs until a variable lookup needs themShea Levy1-0/+1
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>
2012-11-28 nix-env -q --out-path: Support multiple outputsEelco Dolstra1-1/+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-1/+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-1/+1
2012-10-03 Add a ‘--repair’ flag to nix-instantiateEelco Dolstra1-0/+4
This allows repairing corrupted derivations and other source files.
2012-08-13 Add a primop ‘concatLists’Eelco Dolstra1-0/+2
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-12 Add some more evaluations statsEelco Dolstra1-1/+5
2012-08-12 Add some basic profiling support to the evaluatorEelco Dolstra1-2/+14
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-18 Use "#pragma once" to prevent repeated header file inclusionEelco Dolstra1-5/+1
2012-07-17 Remove dead codeEelco Dolstra1-4/+0
2012-02-04 * Inline some functions and get rid of the indirection throughEelco Dolstra1-7/+6
EvalState::eval(). This gives a 12% speedup on ‘nix-instantiate /etc/nixos/nixos/ -A system --readonly-mode’ (from 1.01s to 0.89s).
2012-01-07 * Don't create thunks for simple constants (integers, strings, paths)Eelco Dolstra1-111/+1
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-2/+0
/etc/nixos/nixos -A system" spent about 10% of its time in dynamic_cast.
2011-08-06 * Cache the result of file evaluation (i.e, memoize evalFile()). ThisEelco Dolstra1-0/+9
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 * Allow redirections in search path entries. E.g. if you have aEelco Dolstra1-2/+3
directory /home/eelco/src/stdenv-updates that you want to use as the directory for import such as with (import <nixpkgs> { }); then you can say $ nix-build -I nixpkgs=/home/eelco/src/stdenv-updates
2011-08-06 * Add a Nix expression search path feature. Paths between angleEelco Dolstra1-0/+8
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.
2011-08-06 * Refactoring: move parseExprFromFile() and parseExprFromString() intoEelco Dolstra1-0/+10
the EvalState class.
2011-07-20 * Fix a huuuuge security hole in the Nix daemon. It didn't check thatEelco Dolstra1-4/+0
derivations added to the store by clients have "correct" output paths (meaning that the output paths are computed by hashing the derivation according to a certain algorithm). This means that a malicious user could craft a special .drv file to build *any* desired path in the store with any desired contents (so long as the path doesn't already exist). Then the attacker just needs to wait for a victim to come along and install the compromised path. For instance, if Alice (the attacker) knows that the latest Firefox derivation in Nixpkgs produces the path /nix/store/1a5nyfd4ajxbyy97r1fslhgrv70gj8a7-firefox-5.0.1 then (provided this path doesn't already exist) she can craft a .drv file that creates that path (i.e., has it as one of its outputs), add it to the store using "nix-store --add", and build it with "nix-store -r". So the fake .drv could write a Trojan to the Firefox path. Then, if user Bob (the victim) comes along and does $ nix-env -i firefox $ firefox he executes the Trojan injected by Alice. The fix is to have the Nix daemon verify that derivation outputs are correct (in addValidPath()). This required some refactoring to move the hash computation code to libstore.
2010-10-24 * When allocating an attribute set, reserve enough space for allEelco Dolstra1-3/+1
elements. This prevents the vector from having to resize itself.
2010-10-24 * Keep attribute sets in sorted order to speed up attribute lookups.Eelco Dolstra1-1/+5
* Simplify the representation of attributes in the AST. * Change the behaviour of listToAttrs() in case of duplicate names.
2010-10-24 * Don't create thunks for variable lookups (if possible). ThisEelco Dolstra1-8/+2
significantly reduces the number of values allocated (e.g. from 8.7m to 4.9m for the Bittorrent test).
2010-10-24 * Store attribute sets as a vector instead of a map (i.e. a red-blackEelco Dolstra1-2/+16
tree). This saves a lot of memory. The vector should be sorted so that names can be looked up using binary search, but this is not the case yet. (Surprisingly, looking up attributes using linear search doesn't have a big impact on performance.) Memory consumption for $ nix-instantiate /etc/nixos/nixos/tests -A bittorrent.test --readonly-mode on x86_64-linux with GC enabled is now 185 MiB (compared to 946 MiB on the trunk).
2010-10-23 * Make Value smaller by not storing redundant PrimOp info.Eelco Dolstra1-9/+23
* Clear pointers in Values after overwriting them to make sure that no objects are kept alive unnecessarily.
2010-10-23 * Remove allocValues().Eelco Dolstra1-1/+0
2010-10-22 * In environments, store pointers to values rather than values. ThisEelco Dolstra1-9/+1
improves GC effectiveness a bit more (because a live value doesn't keep other values in the environment plus the parent environments alive), and removes the need for copy nodes.
2010-10-22 * Store Value nodes outside of attribute sets. I.e., Attr now storesEelco Dolstra1-2/+5
a pointer to a Value, rather than the Value directly. This improves the effectiveness of garbage collection a lot: if the Value is stored inside the set directly, then any live pointer to the Value causes all other attributes in the set to be live as well.
2010-10-22 * Make building against the Boehm GC a configure option.Eelco Dolstra1-0/+6
2010-10-20 * Keep some more stats.Eelco Dolstra1-0/+3
2010-10-20 * Use the Boehm garbage collector to reclaim unused memory in the NixEelco Dolstra1-1/+4
expression evaluator.
2010-10-04 * Make sure that config.h is included before the system headers,Eelco Dolstra1-2/+2
because it defines _FILE_OFFSET_BITS. Without this, on OpenSolaris the system headers define it to be 32, and then the 32-bit stat() ends up being called with a 64-bit "struct stat", or vice versa. This also ensures that we get 64-bit file sizes everywhere. * Remove the redundant call to stat() in parseExprFromFile(). The file cannot be a symlink because that's the exit condition of the loop before.
2010-10-04 * Hack needed for GCC 4.3.2 on OpenSolaris.Eelco Dolstra1-1/+1
2010-06-10 * builtins.toXML: propagate the string context. This is a regressionEelco Dolstra1-0/+2
from the old ATerm-based evaluator.
2010-05-18 * The << operator on values should be const.Eelco Dolstra1-1/+1
2010-05-15 * Restore the __overrides feature that was lost somewhere in theEelco Dolstra1-1/+2
fast-eval branch.
2010-05-07 * Keep track of the source positions of attributes.Eelco Dolstra1-1/+10
2010-04-22 * Simplify the implementation of `with'. This gives a 7% speedup inEelco Dolstra1-0/+1
evaluating the NixOS system configuration.
2010-04-22 * String equality tests should take the context into account. All theEelco Dolstra1-1/+1
evaluation test cases now succeed.
2010-04-21 * Fixed builtins.genericClosure.Eelco Dolstra1-1/+1
2010-04-21 * Store user environment manifests as a Nix expression inEelco Dolstra1-1/+10
$out/manifest.nix rather than as an ATerm. (Hm, I thought I committed this two days ago...)