refactor(tvix): Use absl::btree_map for DerivationOutputs
This container implementation is much faster than std::map. We have stuck to an ordered container because it's unclear whether the accesses of this field (of which there are *many*) are actually ordering dependent. Also includes an Arbitrary implementation for absl::btree_map (for any K, V that are also Arbitrary). Change-Id: I04f58ca0ce32b9ae1759313b01508b0e44bae793 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1683 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
a41c3dedb1
commit
91bd7ce73a
4 changed files with 22 additions and 7 deletions
5
third_party/nix/src/libstore/derivations.cc
vendored
5
third_party/nix/src/libstore/derivations.cc
vendored
|
|
@ -40,8 +40,9 @@ BasicDerivation BasicDerivation::from_proto(
|
|||
result.builder = proto_derivation->builder().path();
|
||||
store.assertStorePath(result.builder);
|
||||
|
||||
result.outputs.insert(proto_derivation->outputs().begin(),
|
||||
proto_derivation->outputs().end());
|
||||
for (auto [k, v] : proto_derivation->outputs()) {
|
||||
result.outputs.emplace(k, v);
|
||||
}
|
||||
|
||||
result.inputSrcs.insert(proto_derivation->input_sources().paths().begin(),
|
||||
proto_derivation->input_sources().paths().end());
|
||||
|
|
|
|||
12
third_party/nix/src/libstore/derivations.hh
vendored
12
third_party/nix/src/libstore/derivations.hh
vendored
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
#include <absl/container/btree_map.h>
|
||||
|
||||
#include "libproto/worker.pb.h"
|
||||
#include "libstore/store-api.hh"
|
||||
#include "libutil/hash.hh"
|
||||
|
|
@ -35,16 +37,16 @@ struct DerivationOutput {
|
|||
void parseHashInfo(bool& recursive, Hash& hash) const;
|
||||
};
|
||||
|
||||
// TODO(grfn): change to absl::flat_hash_map
|
||||
typedef std::map<std::string, DerivationOutput> DerivationOutputs;
|
||||
// TODO(tazjin): Determine whether this actually needs to be ordered.
|
||||
using DerivationOutputs = absl::btree_map<std::string, DerivationOutput>;
|
||||
|
||||
/* For inputs that are sub-derivations, we specify exactly which
|
||||
output IDs we are interested in. */
|
||||
// TODO(grfn): change to absl::flat_hash_map
|
||||
typedef std::map<Path, StringSet> DerivationInputs;
|
||||
using DerivationInputs = std::map<Path, StringSet>;
|
||||
|
||||
// TODO(grfn): change to absl::flat_hash_map
|
||||
typedef std::map<std::string, std::string> StringPairs;
|
||||
using StringPairs = std::map<std::string, std::string>;
|
||||
|
||||
struct BasicDerivation {
|
||||
DerivationOutputs outputs; /* keyed on symbolic IDs */
|
||||
|
|
@ -54,7 +56,7 @@ struct BasicDerivation {
|
|||
Strings args;
|
||||
StringPairs env;
|
||||
|
||||
BasicDerivation(){};
|
||||
BasicDerivation() = default;
|
||||
|
||||
// Convert the given proto derivation to a BasicDerivation in the given
|
||||
// nix::Store.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue