about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/attr-set.cc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-19 r/1400 refactor(3p/nix): Rename & undeprecate Bindings::lexicographicOrderVincent Ambo1-1/+1
The function is renamed to `SortedByKeys`, which is more descriptive, and annotated with a comment about what it is used for. The deprecation warning has been removed because this function is currently functionally required. Change-Id: I0ee3a76deff05f366feca9ddac8f38ab34bffbd0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1288 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-16 r/1320 refactor(3p/nix/libexpr): Use range insertion to merge nix::BindingsVincent Ambo1-8/+16
Instead of manually iterating over the two bindings to be combined, this adds a new static method on the Bindings class which merges two attribute sets by calling the range insertion operator over them. In some anecdotal tests, this can lead to a ~10% speed bump - depending on the specific operation. Change-Id: I5dea03b0589a83a789d3a8a0fc81d0d9e6598371 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1216 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-16 r/1305 refactor(3p/nix): Use a static empty Bindings for 0-element attrsVincent Ambo1-2/+11
A significant fraction of all created attribute sets are empty; hence this is an easy optimisation to make. Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: I0884194d04c1ee95b2b239a253515f2152bc0856 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1179 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-15 r/1298 refactor(3p/nix): Revert VectorBindings implementationVincent Ambo1-186/+13
This reverts parts of the CLs splitting the backing implementation for Bindings and moves back to only the BTreeMap-backed implementation. Our evaluation has indicated that the Vector-backed implementation does not match the performance of the plain array used upstream, and in my view the complexity introduced by it is not worth the relatively small (single-digit percentage) performance increase with a pivot-point close to the number of attributes yielded by stdenv.mkDerivation. Going forward we will trial implementations of attribute sets backed by HAMTs, and investigate other mechanisms of speeding up the language. Some changes from the previous CLs are retained, for example the removal of insert_or_assign and the passing of capacity. Change-Id: I6eb4b075b453949583360755055c21a29d7ff642 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1172 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
2020-07-13 r/1289 refactor(3p/nix/libexpr): Backport upstream VectorBindings merge sortVincent Ambo1-17/+28
Since one of the two implementations essentially uses the same shape as the upstream Bindings, we backport their merge sort implementation to ensure that we're doing the same thing semantically. Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: I0d865897991eec0c4dd84d9bd0415cd1ca437792 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1162 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-13 r/1288 fix(3p/nix/libexpr): Remove default & copy constructors for VectorBindingsVincent Ambo1-1/+2
Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: Ief2e59d461452ce599abc63f6ebcfa07a7062491 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1161 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-07-13 r/1287 fix(3p/nix/libexpr): Fix post-increment operator in BindingsIteratorVincent Ambo1-1/+2
We accidentally returned the incremented iterator in the post-increment, this fixes it. Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: I36c79eb56359bb12a78ad3489e7d7d2eb2053510 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1140 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: glittershark <grfn@gws.fyi>
2020-07-13 r/1286 refactor(3p/nix): Remove unused insert_or_assignGriffin Smith1-23/+0
This function in never called, so let's just remove it Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Change-Id: I79125866254d90dd0842bc86830d2103ac313cb6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1125 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: isomer <isomer@tvl.fyi>
2020-07-13 r/1285 feat(3p/nix): Statically pass bindings capacity where possibleGriffin Smith1-22/+34
To aid in making the decision of where to (currently just statically) use a vector or btree as the backing implementation, add an extra constructor argument to Bindings::NewGC for a capacity, and use a (currently hardcoded at 32, for no good reason other than it felt like a reasonable number) pivot to switch between our possible backing implementations. Then, update all the call sites where it feels reasonable that we know the capacity statically to *pass* that capacity to the constructor. Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: I1858c161301a1cd0e83aeeb9a58839378869e71d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1124 Tested-by: BuildkiteCI Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: isomer <isomer@tvl.fyi>
2020-07-13 r/1284 feat(3p/nix): Add vector-backed impl for BindingsGriffin Smith1-8/+138
Add an alternative impl of the now-abstract Bindings base class that is backed by a std::vector, somewhat similar but stylistically a little superior to the array-backed implementation in upstream nix. The underlying iterator type in BindingsIterator is now backed by a std::variant that we std::visit an overload over in order to implement the various bits of the iterator interface. Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: I7fbd1f4d5c449e2f9b82102a701b0bacd5e80672 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1123 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-07-13 r/1283 refactor(3p/nix): Abstract away concrete bindings implGriffin Smith1-14/+52
To pave the way for the thing we want to do eventually which is use a linear-time array for bindings (aka attribute sets) that are statically known to be small enough to get a performance benefit from doing so, make the Bindings class abstract, and define a BTreeBindings class that inherits from it and is (currently always) returned from the static initializer. The idea is that we'll have an ArrayBindings class as well later that we can dispatch to conditionally based on an optional "capacity" parameter or something like that. There was some difficulty here in getting the iterator to work - the approach we settled on ended up making a concrete BindingsIterator class which will wrap a std::variant of either a btree iterator or something else later, but right now just wraps a btree iterator. Paired-With: Luke Granger-Brown <git@lukegb.com> Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: Ie02ca5a1c55e8ebf99ab1e957110bd9284278907 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1121 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi>
2020-07-13 r/1280 refactor(3p/nix/libexpr): Remove the nix::Symbol default constructorVincent Ambo1-1/+1
Having a default constructor for this causes a variety of annoying situations across the codebase in which this is initialised to an unexpected value, leading to constant guarding against those conditions. It turns out there's actually no intrinsic reason that this default constructor needs to exist. The biggest one was addressed in CL/1138 and this commit cleans up the remaining bits. Change-Id: I4a847f50bc90e72f028598196592a7d8730a4e01 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1139 Reviewed-by: isomer <isomer@tvl.fyi> Tested-by: BuildkiteCI
2020-07-04 r/1206 chore(3p/nix/libexpr): Remove dead code from attribute setsVincent Ambo1-2/+0
These bits are no longer required with the hashmap-backed implementation of attribute sets. Change-Id: I8b936d8d438a00bad4ccf8e0b4dd719c559ce8c2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/912 Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu>
2020-05-27 r/865 refactor(3p/nix): Anchor local includes at src/Vincent Ambo1-2/+2
Previously all includes were anchored in one global mess of header files. This moves the includes into filesystem "namespaces" (if you will) for each sub-package of Nix. Note: This commit does not introduce the relevant build system changes.
2020-05-23 r/828 refactor(3p/nix/libexpr): Make other 'const' in Bindings::mergeVincent Ambo1-7/+4
2020-05-23 r/821 fix(3p/nix/libexpr): Remove the global empty attribute setVincent Ambo1-4/+0
In the change to the backing structure of attribute sets, the requirement to manually balance the capacity of the structure went away. This is a) because Abseil's data structures manage this on their own, and b) because the new Bindings class is allocated using `new (GC)` rather than writing into a predefined memory area. As part of this change functions related to the capacity were deprecated and set to 0 values, which in turn caused the creation of new attribute sets to return the same (mutable!) default value in various cases, leading to "side effects" that caused evaluation failures. FWIW, I'm not sure if this optimisation had noticeable performance impact, but while untangling libexpr it definitely doesn't help trying to follow what it's doing - so bye, bye!
2020-05-23 r/818 chore(3p/nix/libexpr): Expose separate insert & "upsert" methodsVincent Ambo1-1/+6
Reading more through the old code, it seems like the intention /sometimes/ is to replace values.
2020-05-22 r/813 fix(3p/nix/libexpr): Do not allow duplicate attribute insertionVincent Ambo1-3/+17
This is closer to bug-for-bug compatibility with the previous version, which would put new elements at the end of the array and (due to the linear scan) return previous ones.
2020-05-22 r/805 refactor(3p/nix/libexpr): state->allocBindings -> Bindings::NewGCVincent Ambo1-5/+2
EvalState::allocBindings had little to do with Bindings, other than returning them, and didn't belong in that class.
2020-05-22 r/804 fix(3p/nix/libexpr): Make new Bindings class visible to GCVincent Ambo1-6/+8
2020-05-22 r/803 chore(3p/nix/libexpr): Delete Bindings::sortVincent Ambo1-3/+0
This function does nothing anymore since the attributes are always in-order.
2020-05-22 r/802 fix(3p/nix): Update for usage of new attribute set APIVincent Ambo1-6/+2
The new attribute set API uses the iterators of the btree_map directly. This requires changes in various files because the internals of libexpr are very entangled. This code runs and compiles, but there is a bug causing empty attribute sets to be assigned incorrectly.
2020-05-22 r/801 refactor(3p/nix/libexpr): Use absl::btree_map::iterator typeVincent Ambo1-3/+8
Instead of using a custom Args* iterator, use the one belonging to the map type directly.
2020-05-22 r/800 refactor(3p/nix/libexpr): Use absl::btree_map::merge for '//'Vincent Ambo1-0/+8
Instead of doing some sort of inline merge-sort of the two attribute sets, use the attribute sets merge function. This commit alone does not build and is not supposed to.
2020-05-21 r/799 refactor(3p/nix/libexpr): Use absl::btree_map for AttrSetsVincent Ambo1-11/+38
This is the first step towards replacing the implementation of attribute sets with an absl::btree_map. Currently many access are done using array offsets and pointer arithmetic, so this change is currently causing Nix to fail in various ways.
2020-05-19 r/777 style(3p/nix): Final act in the brace-wrapping sagaVincent Ambo1-1/+2
This last change set was generated by a full clang-tidy run (including compilation): clang-tidy -p ~/projects/nix-build/ \ -checks=-*,readability-braces-around-statements -fix src/*/*.cc Actually running clang-tidy requires some massaging to make it play nice with Nix + meson, I'll be adding a wrapper or something for that soon.
2020-05-19 r/766 style(3p/nix): Reformat all includes to match new styleVincent Ambo1-0/+2
2020-05-17 r/740 style(3p/nix): Reformat project in Google C++ styleVincent Ambo1-34/+22
Reformatted with: fd . -e hh -e cc | xargs clang-format -i
2020-05-17 r/724 Add 'third_party/nix/' from commit 'be66c7a6b24e3c3c6157fd37b86c7203d14acf10'Vincent Ambo1-0/+52
git-subtree-dir: third_party/nix git-subtree-mainline: cf8cd640c1adf74a3706efbcb0ea4625da106fb2 git-subtree-split: be66c7a6b24e3c3c6157fd37b86c7203d14acf10