mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 06:35:27 +00:00
Auto merge of #90253 - Kobzol:hash-stable-sort-index-map, r=cjgillot
Change several HashMaps to IndexMap to improve incremental hashing performance Stable hashing hash maps in incremental mode takes a lot of time, especially for some benchmarks like `clap`. As noted by `@Mark-Simulacrum` [here](https://github.com/rust-lang/rust/pull/89404#issuecomment-950043892), this cost could be reduced by replacing some hash maps by indexmaps. I gathered some statistics and found several hash maps that took a lot of time to hash and replaced them by indexmaps. However, in order for this to work, we need to make sure that these indexmaps have deterministic insertion order. These three are used only in visitors as far as I can see, which seems deterministic. Can we enforce this somehow? Or should some explaining comment be included for these maps?
This commit is contained in:
commit
c9b45e6010
@ -7,7 +7,7 @@
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
|
||||
|
||||
use crate::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::Node;
|
||||
@ -214,14 +214,14 @@ pub struct ScopeTree {
|
||||
/// conditional expression or repeating block. (Note that the
|
||||
/// enclosing scope ID for the block associated with a closure is
|
||||
/// the closure itself.)
|
||||
pub parent_map: FxHashMap<Scope, (Scope, ScopeDepth)>,
|
||||
pub parent_map: FxIndexMap<Scope, (Scope, ScopeDepth)>,
|
||||
|
||||
/// Maps from a variable or binding ID to the block in which that
|
||||
/// variable is declared.
|
||||
var_map: FxHashMap<hir::ItemLocalId, Scope>,
|
||||
var_map: FxIndexMap<hir::ItemLocalId, Scope>,
|
||||
|
||||
/// Maps from a `NodeId` to the associated destruction scope (if any).
|
||||
destruction_scopes: FxHashMap<hir::ItemLocalId, Scope>,
|
||||
destruction_scopes: FxIndexMap<hir::ItemLocalId, Scope>,
|
||||
|
||||
/// `rvalue_scopes` includes entries for those expressions whose
|
||||
/// cleanup scope is larger than the default. The map goes from the
|
||||
|
Loading…
Reference in New Issue
Block a user