-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Symbol interner into static and dynamic
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.
- Loading branch information
Arlie Davis
committed
Jan 20, 2021
1 parent
14265f9
commit 6fa8898
Showing
8 changed files
with
212 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ tracing = "0.1" | |
sha-1 = "0.9" | ||
sha2 = "0.9" | ||
md-5 = "0.9" | ||
phf = "0.8" |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.