forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#82183 - michaelwoerister:lazier-defpathhash-l…
…oading2, r=wesleywiser Simplify lazy DefPathHash decoding by using an on-disk hash table. This PR simplifies the logic around mapping `DefPathHash` values encountered during incremental compilation to valid `DefId`s in the current session. It is able to do so by using an on-disk hash table encoding that allows for looking up values directly, i.e. without deserializing the entire table. The main simplification comes from not having to keep track of `DefPathHashes` being used during the compilation session.
- Loading branch information
Showing
22 changed files
with
279 additions
and
350 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use rustc_data_structures::fingerprint::Fingerprint; | ||
use rustc_span::def_id::{DefIndex, DefPathHash}; | ||
|
||
#[derive(Clone, Default)] | ||
pub struct Config; | ||
|
||
impl odht::Config for Config { | ||
type Key = DefPathHash; | ||
type Value = DefIndex; | ||
|
||
type EncodedKey = [u8; 16]; | ||
type EncodedValue = [u8; 4]; | ||
|
||
type H = odht::UnHashFn; | ||
|
||
#[inline] | ||
fn encode_key(k: &DefPathHash) -> [u8; 16] { | ||
k.0.to_le_bytes() | ||
} | ||
|
||
#[inline] | ||
fn encode_value(v: &DefIndex) -> [u8; 4] { | ||
v.as_u32().to_le_bytes() | ||
} | ||
|
||
#[inline] | ||
fn decode_key(k: &[u8; 16]) -> DefPathHash { | ||
DefPathHash(Fingerprint::from_le_bytes(*k)) | ||
} | ||
|
||
#[inline] | ||
fn decode_value(v: &[u8; 4]) -> DefIndex { | ||
DefIndex::from_u32(u32::from_le_bytes(*v)) | ||
} | ||
} | ||
|
||
pub type DefPathHashMap = odht::HashTableOwned<Config>; |
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
Oops, something went wrong.