You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This improves performance of Symbol interning in several ways.
The main motivation of this work is to prepare rustc for
efficient parallel builds.
The Symbol lookup table (mapping from strings to Symbol numbers)
is now split into two separate tables: a static table and a
dynamic table. The static table contains strings that are known
to rustc, including all keywords and all `sym::foo` symbols.
The dynamic table contains strings that rustc discovers while
compiling, such as "my_super_obscure_function_name".
Since the static table is known at compile time (that is, when
rustc itself is being compiled), this table can be stored
entirely in static data structures. We use the `phf` crate to
generate this table; `phf` generates perfect hash functions.
This allows rustc to perform Symbol lookups for static symbols
without any multithreaded synchronization, or accessing any
dynamic data whatsoever.
I measured the percentage of static symbol lookups in many
common Rust crates, including rust/compiler, rust/library,
servo, rand, quote, syn, rust-analyzer, rayon, and rsvg.
Among these crates, between 35% and 55% of all symbol lookups
were resolved using the static lookup table.
0 commit comments