about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
AgeCommit message (Collapse)AuthorLines
2022-01-11Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, ↵bors-4/+4
r=Mark-Simulacrum Replace usages of vec![].into_iter with [].into_iter `[].into_iter` is idiomatic over `vec![].into_iter` because its simpler and faster (unless the vec is optimized away in which case it would be the same) So we should change all the implementation, documentation and tests to use it. I skipped: * `src/tools` - Those are copied in from upstream * `src/test/ui` - Hard to tell if `vec![].into_iter` was used intentionally or not here and not much benefit to changing it. * any case where `vec![].into_iter` was used because we specifically needed a `Vec::IntoIter<T>` * any case where it looked like we were intentionally using `vec![].into_iter` to test it.
2022-01-10Update rayon and rustc-rayonJosh Stone-2/+2
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-4/+4
2022-01-05Ensure that `Fingerprint` caching respects hashing configurationAaron Hill-0/+19
Fixes #92266 In some `HashStable` impls, we use a cache to avoid re-computing the same `Fingerprint` from the same structure (e.g. an `AdtDef`). However, the `StableHashingContext` used can be configured to perform hashing in different ways (e.g. skipping `Span`s). This configuration information is not included in the cache key, which will cause an incorrect `Fingerprint` to be used if we hash the same structure with different `StableHashingContext` settings. To fix this, the configuration settings of `StableHashingContext` are split out into a separate `HashingControls` struct. This struct is used as part of the cache key, ensuring that our caches always produce the correct result for the given settings. With this in place, we now turn off `Span` hashing during the entire process of computing the hash included in legacy symbols. This current has no effect, but will matter when a future PR starts hashing more `Span`s that we currently skip.
2022-01-04Do not hash zero bytes of i64 and u32 in Sip128 hasherJakub Beránek-2/+16
2022-01-03Make `Fingerprint::combine_commutative` associativeTomasz Miąsko-1/+18
The previous implementation swapped lower and upper 64-bits of a result of modular addition, so the function was non-associative.
2022-01-01Rustdoc: use ThinVec for GenericArgs bindingsJakub Beránek-5/+9
2021-12-28Auto merge of #92130 - Kobzol:stable-hash-str, r=cjgillotbors-3/+2
Use hash_stable for hashing str This seemed like an oversight. With this change the hash can go through the `HashStable` machinery directly.
2021-12-22rustc `VecGraph`: require the index type to implement Ordpierwill-6/+9
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+1
Implement `Ord`, `PartialOrd` for SpanData
2021-12-21Auto merge of #91903 - tmiasko:bit-set-hash, r=jackh726bors-4/+31
Implement StableHash for BitSet and BitMatrix via Hash This fixes an issue where bit sets / bit matrices the same word content but a different domain size would receive the same hash.
2021-12-20Use hash_stable for hashing strJakub Beránek-3/+2
2021-12-18Auto merge of #91837 - Kobzol:stable-hash-map-avoid-sort, r=the8472bors-23/+43
Avoid sorting in hash map stable hashing Suggested by `@the8472` [here](https://github.com/rust-lang/rust/pull/89404#issuecomment-991813333). I hope that I understood it right, I replaced the sort with modular multiplication, which should be commutative. Can I ask for a perf. run? However, locally it didn't help at all. Creating the `StableHasher` all over again is probably slowing it down quite a lot. And using `FxHasher` is not straightforward, because the keys and values only implement `HashStable` (and probably they shouldn't be just hashed via `Hash` anyway for it to actually be stable). Maybe the `StableHash` interface could be changed somehow to better suppor these scenarios where the hasher is short-lived. Or the `StableHasher` implementation could have variants with e.g. a shorter buffer for these scenarios.
2021-12-18Implement StableHash for BitSet and BitMatrix via HashTomasz Miąsko-4/+31
This fixes an issue where bit sets / bit matrices the same word content but a different domain size would receive the same hash.
2021-12-13Add special case for length 1Jakub Beránek-9/+17
2021-12-13Remove sort from hashing hashset, treeset and treemapJakub Beránek-27/+29
2021-12-12Use modular arithmeticJakub Beránek-3/+3
2021-12-12Auto merge of #91549 - fee1-dead:const_env, r=spastorinobors-0/+2
Eliminate ConstnessAnd again Closes #91489. Closes #89432. Reverts #91491. Reverts #89450. r? `@spastorino`
2021-12-12Avoid sorting in hash map stable hashingJakub Beránek-4/+14
2021-12-12Small performance tweaksDeadbeef-0/+2
2021-12-12Auto merge of #89404 - Kobzol:hash-stable-sort, r=Mark-Simulacrumbors-1/+2
Slightly optimize hash map stable hashing I was profiling some of the `rustc-perf` benchmarks locally and noticed that quite some time is spent inside the stable hash of hashmaps. I tried to use a `SmallVec` instead of a `Vec` there, which helped very slightly. Then I tried to remove the sorting, which was a bottleneck, and replaced it with insertion into a binary heap. Locally, it yielded nice improvements in instruction counts and RSS in several benchmarks for incremental builds. The implementation could probably be much nicer and possibly extended to other stable hashes, but first I wanted to test the perf impact properly. Can I ask someone to do a perf run? Thank you!
2021-12-11Rollup merge of #91426 - eggyal:idfunctor-panic-safety, r=lcnrMatthias Krüger-24/+30
Make IdFunctor::try_map_id panic-safe Addresses FIXME comment created in #78313 r? ```@lcnr```
2021-12-09Remove redundant [..]sest31-4/+4
2021-12-07Make IdFunctor::try_map_id panic-safeAlan Egerton-24/+30
2021-12-06Annotate comments onto the LT algorithmMark Rousskov-2/+102
2021-12-06Avoid using Option where values are always SomeMark Rousskov-9/+13
2021-12-06Create newtype around the pre order indexMark Rousskov-32/+41
2021-12-06Use variables rather than lengths directlyMark Rousskov-10/+13
2021-12-06Optimize: reuse the real-to-preorder mapping as the visited setMark Rousskov-4/+2
2021-12-06Remove separate RPO traversalMark Rousskov-17/+7
This integrates the preorder and postorder traversals into one.
2021-12-06Use preorder indices for data structuresMark Rousskov-53/+38
This largely avoids remapping from and to the 'real' indices, with the exception of predecessor lookup and the final merge back, and is conceptually better.
2021-12-06Avoid inserting into buckets if not necessaryMark Rousskov-1/+7
2021-12-06Optimization: process buckets only onceMark Rousskov-7/+8
2021-12-06Optimization: Merge parent and ancestor arraysMark Rousskov-10/+21
As the paper indicates, the unprocessed vertices in the DFS tree and processed vertices are disjoint, and we can use them in the same space, tracking only the index of the split.
2021-12-06Implement the simple Lengauer-Tarjan algorithmMark Rousskov-39/+116
This replaces the previous implementation with the simple variant of Lengauer-Tarjan, which performs better in the general case. Performance on the keccak benchmark is about equivalent between the two, but we don't see regressions (and indeed see improvements) on other benchmarks, even on a partially optimized implementation. The implementation here follows that of the pseudocode in "Linear-Time Algorithms for Dominators and Related Problems" thesis by Loukas Georgiadis. The next few commits will optimize the implementation as suggested in the thesis. Several related works are cited in the comments within the implementation, as well. Implement the simple Lengauer-Tarjan algorithm This replaces the previous implementation (from #34169), which has not been optimized since, with the simple variant of Lengauer-Tarjan which performs better in the general case. A previous attempt -- not kept in commit history -- attempted a replacement with a bitset-based implementation, but this led to regressions on perf.rust-lang.org benchmarks and equivalent wins for the keccak benchmark, so was rejected. The implementation here follows that of the pseudocode in "Linear-Time Algorithms for Dominators and Related Problems" thesis by Loukas Georgiadis. The next few commits will optimize the implementation as suggested in the thesis. Several related works are cited in the comments within the implementation, as well. On the keccak benchmark, we were previously spending 15% of our cycles computing the NCA / intersect function; this function is quite expensive, especially on modern CPUs, as it chases pointers on every iteration in a tight loop. With this commit, we spend ~0.05% of our time in dominator computation.
2021-12-05Stop enabling `in_band_lifetimes` in rustc_data_structuresScott McMurray-15/+13
There's a conversation in the tracking issue about possibly unaccepting `in_band_lifetimes`, but it's used heavily in the compiler, and thus there'd need to be a bunch of PRs like this if that were to happen. So here's one to see how much of an impact it has. (Oh, and I removed `nll` while I was here too, since it didn't seem needed. Let me know if I should put that back.)
2021-12-03Rollup merge of #88906 - Kixunil:box-maybe-uninit-write, r=dtolnayMatthias Krüger-4/+2
Implement write() method for Box<MaybeUninit<T>> This adds method similar to `MaybeUninit::write` main difference being it returns owned `Box`. This can be used to elide copy from stack safely, however it's not currently tested that the optimization actually occurs. Analogous methods are not provided for `Rc` and `Arc` as those need to handle the possibility of sharing. Some version of them may be added in the future. This was discussed in #63291 which this change extends.
2021-12-02Implement write() method for Box<MaybeUninit<T>>Martin Habovstiak-4/+2
This adds method similar to `MaybeUninit::write` main difference being it returns owned `Box`. This can be used to elide copy from stack safely, however it's not currently tested that the optimization actually occurs. Analogous methods are not provided for `Rc` and `Arc` as those need to handle the possibility of sharing. Some version of them may be added in the future. This was discussed in #63291 which this change extends.
2021-12-02Remove no-longer used `IdFunctor::map_id`Alan Egerton-9/+0
2021-11-27Use intrinsic pointer methodsAlan Egerton-7/+5
2021-11-27Delegate from `map_id` to `try_map_id`Alan Egerton-57/+7
2021-11-27Avoid UB when short-circuiting try_map_id for VecAlan Egerton-4/+11
2021-11-26Make `TypeFoldable` implementors short-circuit on errorLeSeulArtichaut-1/+69
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-11Add `#[inline]`s to `SortedIndexMultiMap`Yuki Okushi-0/+10
2021-11-07more clippy fixesMatthias Krüger-1/+1
2021-10-29Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnrbors-1/+0
Revert "Add rustc lint, warning when iterating over hashmaps" Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-28Auto merge of #90145 - cjgillot:sorted-map, r=michaelwoeristerbors-5/+22
Use SortedMap in HIR. Closes https://github.com/rust-lang/rust/issues/89788 r? `@ghost`
2021-10-25Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrumbors-1/+0
Bump bootstrap compiler to 1.57 Fixes https://github.com/rust-lang/rust/issues/90152 r? `@Mark-Simulacrum`
2021-10-25Use SmallVec in Hash map stable hashingJakub Beránek-1/+2