This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Replace bimap dependency with a more efficient pair of maps, and arena-allocate slices.#951
Merged
eddyb merged 3 commits intoEmbarkStudios:mainfrom Nov 30, 2022
LykenSol:un-bimap
Merged
Replace bimap dependency with a more efficient pair of maps, and arena-allocate slices.#951eddyb merged 3 commits intoEmbarkStudios:mainfrom LykenSol:un-bimap
bimap dependency with a more efficient pair of maps, and arena-allocate slices.#951eddyb merged 3 commits intoEmbarkStudios:mainfrom
LykenSol:un-bimap
Conversation
Merged
oisyn
approved these changes
Nov 30, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This originally was a prerequisite for introducing some asymmetry (for finer-grained zombies) in the maps, which
bimapmade impossible because it guarantees 1:1 (even when usinginsertinstead ofinsert_no_overwrite, what it does is it removes any entries related to either side first, then adds the new pair of entries).But it turned into a refactor of its own, once I realized I can get rid of per-entry allocations, using the power of
tcx.arena.dropless. (an untyped arena that allows allocating individual values, or whole slices, as long as they're!Drop- this works great because there is no "drop to remember", which reduces overhead and soundness complexity - and by using the slice feature, at the very leastVecs can be replaced, and even entire data-recursive trees could be arena-allocated, even if it sadly doesn't generalize to e.g.HashMap/BTreeMap)I haven't profiled this but it might be a bit faster? We were being pretty wasteful before, esp.
lookup_typewould.clone()variants ofSpirvTypethat hadVecs in them, whereas now it's merely copying&[T]s.Probably best to review each commit separately, matching the refactor stages.