Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perf Experiment] Change FxHash to GxHash #127040

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 25 additions & 9 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ dependencies = [
"fluent-syntax",
"intl-memoizer",
"intl_pluralrules",
"rustc-hash",
"rustc-hash 1.1.0",
"self_cell 0.10.3",
"smallvec",
"unic-langid",
Expand Down Expand Up @@ -1646,6 +1646,15 @@ dependencies = [
"serde",
]

[[package]]
name = "gxhash"
version = "3.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a197c9b654827513cf53842c5c6d3da2b4b35a785f8e0eff78bdf8e445aba1bb"
dependencies = [
"rustversion",
]

[[package]]
name = "handlebars"
version = "5.1.2"
Expand Down Expand Up @@ -2074,7 +2083,7 @@ dependencies = [
"anyhow",
"clap",
"fs-err",
"rustc-hash",
"rustc-hash 1.1.0",
"rustdoc-json-types",
"serde",
"serde_json",
Expand Down Expand Up @@ -2406,7 +2415,7 @@ dependencies = [
"memmap2",
"parking_lot",
"perf-event-open-sys",
"rustc-hash",
"rustc-hash 1.1.0",
"smallvec",
]

Expand Down Expand Up @@ -3016,7 +3025,7 @@ checksum = "c4e8e505342045d397d0b6674dcb82d6faf5cf40484d30eeb88fc82ef14e903f"
dependencies = [
"datafrog",
"log",
"rustc-hash",
"rustc-hash 1.1.0",
]

[[package]]
Expand Down Expand Up @@ -3448,6 +3457,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"

[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"

[[package]]
name = "rustc-main"
version = "0.0.0"
Expand Down Expand Up @@ -3817,14 +3832,15 @@ dependencies = [
"either",
"elsa",
"ena",
"gxhash",
"indexmap",
"jobserver",
"libc",
"measureme",
"memmap2",
"parking_lot",
"portable-atomic",
"rustc-hash",
"rustc-hash 2.0.0",
"rustc-rayon",
"rustc_arena",
"rustc_graphviz",
Expand Down Expand Up @@ -4512,7 +4528,7 @@ dependencies = [
name = "rustc_pattern_analysis"
version = "0.0.0"
dependencies = [
"rustc-hash",
"rustc-hash 1.1.0",
"rustc_apfloat",
"rustc_arena",
"rustc_data_structures",
Expand Down Expand Up @@ -4904,7 +4920,7 @@ name = "rustdoc-json-types"
version = "0.1.0"
dependencies = [
"bincode",
"rustc-hash",
"rustc-hash 1.1.0",
"serde",
"serde_json",
]
Expand Down Expand Up @@ -5632,7 +5648,7 @@ dependencies = [
"ignore",
"miropt-test-tools",
"regex",
"rustc-hash",
"rustc-hash 1.1.0",
"semver",
"similar",
"termcolor",
Expand Down Expand Up @@ -5886,7 +5902,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb68604048ff8fa93347f02441e4487594adc20bb8a084f9e564d2b827a0a9f"
dependencies = [
"rustc-hash",
"rustc-hash 1.1.0",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions blah.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hola1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¡Hola! 👋

6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ptr::P;
use crate::Expr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::gx::GxHashMap;
use rustc_macros::{Decodable, Encodable};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span;
Expand Down Expand Up @@ -65,14 +65,14 @@ pub struct FormatArguments {
arguments: Vec<FormatArgument>,
num_unnamed_args: usize,
num_explicit_args: usize,
names: FxHashMap<Symbol, usize>,
names: GxHashMap<Symbol, usize>,
}

impl FormatArguments {
pub fn new() -> Self {
Self {
arguments: Vec::new(),
names: FxHashMap::default(),
names: GxHashMap::default(),
num_unnamed_args: 0,
num_explicit_args: 0,
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::LoweringContext;

use rustc_ast::ptr::P;
use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::gx::{GxHashMap, GxHashSet, GxIndexMap};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_session::parse::feature_err;
Expand Down Expand Up @@ -68,7 +68,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.emit();
}

let mut clobber_abis = FxIndexMap::default();
let mut clobber_abis = GxIndexMap::default();
if let Some(asm_arch) = asm_arch {
for (abi_name, abi_span) in &asm.clobber_abis {
match asm::InlineAsmClobberAbi::parse(asm_arch, &self.tcx.sess.target, *abi_name) {
Expand Down Expand Up @@ -318,8 +318,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}

let mut used_input_regs = FxHashMap::default();
let mut used_output_regs = FxHashMap::default();
let mut used_input_regs = GxHashMap::default();
let mut used_output_regs = GxHashMap::default();

for (idx, &(ref op, op_sp)) in operands.iter().enumerate() {
if let Some(reg) = op.reg() {
Expand Down Expand Up @@ -362,7 +362,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// Flag to output the error only once per operand
let mut skip = false;

let mut check = |used_regs: &mut FxHashMap<asm::InlineAsmReg, usize>,
let mut check = |used_regs: &mut GxHashMap<asm::InlineAsmReg, usize>,
input,
r: asm::InlineAsmReg| {
match used_regs.entry(r) {
Expand Down Expand Up @@ -436,7 +436,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

// If a clobber_abi is specified, add the necessary clobbers to the
// operands list.
let mut clobbered = FxHashSet::default();
let mut clobbered = GxHashSet::default();
for (abi, (_, abi_span)) in clobber_abis {
for &clobber in abi.clobbered_regs() {
// Don't emit a clobber for a register already clobbered
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::ops::ControlFlow;
use rustc_ast as ast;
use rustc_ast::visit::Visitor;
use rustc_ast::*;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::gx::GxIndexMap;
use rustc_hir as hir;
use rustc_span::{
sym,
Expand Down Expand Up @@ -282,7 +282,7 @@ fn make_count<'hir>(
ctx: &mut LoweringContext<'_, 'hir>,
sp: Span,
count: &Option<FormatCount>,
argmap: &mut FxIndexMap<(usize, ArgumentType), Option<Span>>,
argmap: &mut GxIndexMap<(usize, ArgumentType), Option<Span>>,
) -> hir::Expr<'hir> {
match count {
Some(FormatCount::Literal(n)) => {
Expand Down Expand Up @@ -335,7 +335,7 @@ fn make_format_spec<'hir>(
ctx: &mut LoweringContext<'_, 'hir>,
sp: Span,
placeholder: &FormatPlaceholder,
argmap: &mut FxIndexMap<(usize, ArgumentType), Option<Span>>,
argmap: &mut GxIndexMap<(usize, ArgumentType), Option<Span>>,
) -> hir::Expr<'hir> {
let position = match placeholder.argument.index {
Ok(arg_index) => {
Expand Down Expand Up @@ -432,7 +432,7 @@ fn expand_format_args<'hir>(

// Create a list of all _unique_ (argument, format trait) combinations.
// E.g. "{0} {0:x} {0} {1}" -> [(0, Display), (0, LowerHex), (1, Display)]
let mut argmap = FxIndexMap::default();
let mut argmap = GxIndexMap::default();
for piece in &fmt.template {
let FormatArgsPiece::Placeholder(placeholder) = piece else { continue };
if placeholder.format_options != Default::default() {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use rustc_ast::{self as ast, *};
use rustc_ast_pretty::pprust;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::gx::GxIndexSet;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
Expand Down Expand Up @@ -1630,7 +1630,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
opaque_ty_node_id: NodeId,
origin: hir::OpaqueTyOrigin,
in_trait: bool,
captured_lifetimes_to_duplicate: FxIndexSet<Lifetime>,
captured_lifetimes_to_duplicate: GxIndexSet<Lifetime>,
span: Span,
opaque_ty_span: Span,
lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>],
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/lifetime_collector.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::ResolverAstLoweringExt;
use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
use rustc_ast::{GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind};
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::gx::GxIndexSet;
use rustc_hir::def::{DefKind, LifetimeRes, Res};
use rustc_middle::span_bug;
use rustc_middle::ty::ResolverAstLowering;
Expand All @@ -11,12 +11,12 @@ use rustc_span::Span;
struct LifetimeCollectVisitor<'ast> {
resolver: &'ast ResolverAstLowering,
current_binders: Vec<NodeId>,
collected_lifetimes: FxIndexSet<Lifetime>,
collected_lifetimes: GxIndexSet<Lifetime>,
}

impl<'ast> LifetimeCollectVisitor<'ast> {
fn new(resolver: &'ast ResolverAstLowering) -> Self {
Self { resolver, current_binders: Vec::new(), collected_lifetimes: FxIndexSet::default() }
Self { resolver, current_binders: Vec::new(), collected_lifetimes: GxIndexSet::default() }
}

fn record_lifetime_use(&mut self, lifetime: Lifetime) {
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'ast> Visitor<'ast> for LifetimeCollectVisitor<'ast> {
pub(crate) fn lifetimes_in_bounds(
resolver: &ResolverAstLowering,
bounds: &GenericBounds,
) -> FxIndexSet<Lifetime> {
) -> GxIndexSet<Lifetime> {
let mut visitor = LifetimeCollectVisitor::new(resolver);
for bound in bounds {
visitor.visit_param_bound(bound, BoundKind::Bound);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_ast::ptr::P;
use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
use rustc_ast::*;
use rustc_ast_pretty::pprust::{self, State};
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::gx::GxIndexMap;
use rustc_errors::DiagCtxtHandle;
use rustc_feature::Features;
use rustc_parse::validate_attr;
Expand Down Expand Up @@ -828,7 +828,7 @@ impl<'a> AstValidator<'a> {
/// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`)
fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericParam], span: Span) {
let mut max_param: Option<ParamKindOrd> = None;
let mut out_of_order = FxIndexMap::default();
let mut out_of_order = GxIndexMap::default();
let mut param_idents = Vec::with_capacity(generics.len());

for (idx, param) in generics.iter().enumerate() {
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::path_utils::allow_two_phase_borrow;
use crate::place_ext::PlaceExt;
use crate::BorrowIndex;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::gx::{GxIndexMap, GxIndexSet};
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::traversal;
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
Expand All @@ -18,16 +18,16 @@ pub struct BorrowSet<'tcx> {
/// by the `Location` of the assignment statement in which it
/// appears on the right hand side. Thus the location is the map
/// key, and its position in the map corresponds to `BorrowIndex`.
pub location_map: FxIndexMap<Location, BorrowData<'tcx>>,
pub location_map: GxIndexMap<Location, BorrowData<'tcx>>,

/// Locations which activate borrows.
/// NOTE: a given location may activate more than one borrow in the future
/// when more general two-phase borrow support is introduced, but for now we
/// only need to store one borrow index.
pub activation_map: FxIndexMap<Location, Vec<BorrowIndex>>,
pub activation_map: GxIndexMap<Location, Vec<BorrowIndex>>,

/// Map from local to all the borrows on that local.
pub local_map: FxIndexMap<mir::Local, FxIndexSet<BorrowIndex>>,
pub local_map: GxIndexMap<mir::Local, GxIndexSet<BorrowIndex>>,

pub locals_state_at_exit: LocalsStateAtExit,
}
Expand Down Expand Up @@ -174,9 +174,9 @@ impl<'tcx> BorrowSet<'tcx> {
struct GatherBorrows<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
body: &'a Body<'tcx>,
location_map: FxIndexMap<Location, BorrowData<'tcx>>,
activation_map: FxIndexMap<Location, Vec<BorrowIndex>>,
local_map: FxIndexMap<mir::Local, FxIndexSet<BorrowIndex>>,
location_map: GxIndexMap<Location, BorrowData<'tcx>>,
activation_map: GxIndexMap<Location, Vec<BorrowIndex>>,
local_map: GxIndexMap<mir::Local, GxIndexSet<BorrowIndex>>,

/// When we encounter a 2-phase borrow statement, it will always
/// be assigning into a temporary TEMP:
Expand All @@ -186,7 +186,7 @@ struct GatherBorrows<'a, 'tcx> {
/// We add TEMP into this map with `b`, where `b` is the index of
/// the borrow. When we find a later use of this activation, we
/// remove from the map (and add to the "tombstone" set below).
pending_activations: FxIndexMap<mir::Local, BorrowIndex>,
pending_activations: GxIndexMap<mir::Local, BorrowIndex>,

locals_state_at_exit: LocalsStateAtExit,
}
Expand Down
Loading
Loading