Skip to content

proc_macro bridge fxhash perf testing #134434

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

Closed
wants to merge 1 commit 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 0 additions & 113 deletions library/proc_macro/src/bridge/fxhash.rs

This file was deleted.

6 changes: 3 additions & 3 deletions library/proc_macro/src/bridge/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::num::NonZero;
use std::ops::{Index, IndexMut};
use std::sync::atomic::{AtomicU32, Ordering};

use super::fxhash::FxHashMap;
use super::DeterministicHashMap;

pub(super) type Handle = NonZero<u32>;

Expand Down Expand Up @@ -56,12 +56,12 @@ impl<T> IndexMut<Handle> for OwnedStore<T> {
/// Like `OwnedStore`, but avoids storing any value more than once.
pub(super) struct InternedStore<T: 'static> {
owned: OwnedStore<T>,
interner: FxHashMap<T, Handle>,
interner: DeterministicHashMap<T, Handle>,
}

impl<T: Copy + Eq + Hash> InternedStore<T> {
pub(super) fn new(counter: &'static AtomicU32) -> Self {
InternedStore { owned: OwnedStore::new(counter), interner: FxHashMap::default() }
InternedStore { owned: OwnedStore::new(counter), interner: DeterministicHashMap::default() }
}

pub(super) fn alloc(&mut self, x: T) -> Handle {
Expand Down
7 changes: 4 additions & 3 deletions library/proc_macro/src/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

#![deny(unsafe_code)]

use std::hash::Hash;
use std::collections::HashMap;
use std::hash::{BuildHasherDefault, DefaultHasher, Hash};
use std::ops::{Bound, Range};
use std::sync::Once;
use std::{fmt, marker, mem, panic, thread};

use crate::{Delimiter, Level, Spacing};

type DeterministicHashMap<K, V> = HashMap<K, V, BuildHasherDefault<DefaultHasher>>;

/// Higher-order macro describing the server RPC API, allowing automatic
/// generation of type-safe Rust APIs, both client-side and server-side.
///
Expand Down Expand Up @@ -155,8 +158,6 @@ pub mod client;
#[allow(unsafe_code)]
mod closure;
#[forbid(unsafe_code)]
mod fxhash;
#[forbid(unsafe_code)]
mod handle;
#[macro_use]
#[forbid(unsafe_code)]
Expand Down
4 changes: 2 additions & 2 deletions library/proc_macro/src/bridge/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<S> DecodeMut<'_, '_, S> for Symbol {
thread_local! {
static INTERNER: RefCell<Interner> = RefCell::new(Interner {
arena: arena::Arena::new(),
names: fxhash::FxHashMap::default(),
names: DeterministicHashMap::default(),
strings: Vec::new(),
// Start with a base of 1 to make sure that `NonZero<u32>` works.
sym_base: NonZero::new(1).unwrap(),
Expand All @@ -141,7 +141,7 @@ struct Interner {
// SAFETY: These `'static` lifetimes are actually references to data owned
// by the Arena. This is safe, as we never return them as static references
// from `Interner`.
names: fxhash::FxHashMap<&'static str, Symbol>,
names: DeterministicHashMap<&'static str, Symbol>,
strings: Vec<&'static str>,
// The offset to apply to symbol names stored in the interner. This is used
// to ensure that symbol names are not re-used after the interner is
Expand Down
Loading