rust/src/librustc_data_structures
bors 66363b2881 Auto merge of #50240 - nnethercote:LazyBTreeMap, r=cramertj
Implement LazyBTreeMap and use it in a few places.

This is a thin wrapper around BTreeMap that avoids allocating upon creation.

I would prefer to change BTreeMap directly to make it lazy (like I did with HashSet in #36734) and I initially attempted that by making BTreeMap::root an Option<>. But then I also had to change Iter and Range to handle trees with no root, and those types have stability markers on them and I wasn't sure if that was acceptable. Also, BTreeMap has a lot of complex code and changing it all was challenging, and I didn't have high confidence about my general approach.

So I prototyped this wrapper instead and used it in the hottest locations to get some measurements about the effect. The measurements are pretty good!

- Doing a debug build of serde, it reduces the total number of heap allocations from 17,728,709 to 13,359,384, a 25% reduction. The number of bytes allocated drops from 7,474,672,966 to 5,482,308,388, a 27% reduction.

- It gives speedups of up to 3.6% on some rustc-perf benchmark jobs. crates.io, futures, and serde benefit most.
```
futures-check
        avg: -1.9%      min: -3.6%      max: -0.5%
serde-check
        avg: -2.1%      min: -3.5%      max: -0.7%
crates.io-check
        avg: -1.7%      min: -3.5%      max: -0.3%
serde
        avg: -2.0%      min: -3.0%      max: -0.9%
serde-opt
        avg: -1.8%      min: -2.9%      max: -0.3%
futures
        avg: -1.5%      min: -2.8%      max: -0.4%
tokio-webpush-simple-check
        avg: -1.1%      min: -2.2%      max: -0.1%
futures-opt
        avg: -1.2%      min: -2.1%      max: -0.4%
piston-image-check
        avg: -0.8%      min: -1.1%      max: -0.3%
crates.io
        avg: -0.6%      min: -1.0%      max: -0.3%
```
@Gankro, how do you think I should proceed here? Is leaving this as a wrapper reasonable? Or should I try to make BTreeMap itself lazy? If so, can I change the representation of Iter and Range?

Thanks!
2018-04-28 21:19:33 +00:00
..
control_flow_graph Fix docs for future pulldown migration 2018-01-01 14:44:12 +01:00
graph Implement some trivial size_hints for various iterators 2018-03-20 05:33:59 -04:00
obligation_forest Use num::NonZero* instead of NonZero<_> in rustc and tests 2018-03-17 23:07:40 +01:00
owning_ref Make metadata references Send + Sync 2018-03-07 01:56:59 +01:00
snapshot_map Generate documentation for auto-trait impls 2018-02-18 16:29:24 -05:00
accumulate_vec.rs Move RangeArguments to {core::std}::ops and rename to RangeBounds 2018-03-29 13:12:49 +02:00
array_vec.rs Auto merge of #48945 - clarcharr:iter_exhaust, r=Kimundi 2018-04-16 13:21:56 +00:00
base_n.rs Shorten names of some compiler generated artifacts. 2018-01-08 12:30:52 +01:00
bitslice.rs rustc_data_structures: add missing #[inline]. 2018-02-21 19:21:26 +02:00
bitvec.rs Implement some trivial size_hints for various iterators 2018-03-20 05:33:59 -04:00
Cargo.toml rustc_target: move in syntax::abi and flip dependency. 2018-04-26 17:49:16 +03:00
flock.rs Fix definitions of ULONG_PTR 2017-05-06 15:46:16 +01:00
fx.rs rustc: Remove some dead code 2017-08-19 13:27:16 +03:00
indexed_set.rs avoid IdxSets containing garbage above the universe length 2018-04-02 00:14:44 +03:00
indexed_vec.rs Move RangeArguments to {core::std}::ops and rename to RangeBounds 2018-03-29 13:12:49 +02:00
lazy_btree_map.rs Implement LazyBTreeMap and use it in a few places. 2018-04-26 11:55:06 +10:00
lib.rs Auto merge of #50240 - nnethercote:LazyBTreeMap, r=cramertj 2018-04-28 21:19:33 +00:00
sip128.rs rustc_data_structures: Add implementation of 128 bit SipHash. 2017-10-16 14:44:40 +02:00
small_vec.rs Fix typos & us spellings 2017-08-15 21:56:30 +02:00
stable_hasher.rs Move PROFQ_CHAN to a Session field 2018-03-09 08:04:31 +01:00
sync.rs Add a Once type for values which are only written once 2018-04-10 14:39:33 +02:00
transitive_relation.rs Make TransitiveRelation thread safe. Avoid locking by using get_mut in some cases. 2018-02-27 19:07:33 +01:00
tuple_slice.rs Add additional test cases to test all arities of tuple; And remove type suffix - i32 on integers 2016-06-11 22:31:24 +05:30