Use PackedFingerprint in DepNode to reduce memory consumption

This commit is contained in:
Tyson Nottingham 2020-11-03 22:23:08 -08:00
parent 8d2d001492
commit f09d474836
4 changed files with 60 additions and 9 deletions

View file

@ -44,7 +44,7 @@
use super::{DepContext, DepKind};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use std::fmt;
@ -53,7 +53,7 @@ use std::hash::Hash;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
pub struct DepNode<K> {
pub kind: K,
pub hash: Fingerprint,
pub hash: PackedFingerprint,
}
impl<K: DepKind> DepNode<K> {
@ -62,7 +62,7 @@ impl<K: DepKind> DepNode<K> {
/// does not require any parameters.
pub fn new_no_params(kind: K) -> DepNode<K> {
debug_assert!(!kind.has_params());
DepNode { kind, hash: Fingerprint::ZERO }
DepNode { kind, hash: PackedFingerprint(Fingerprint::ZERO) }
}
pub fn construct<Ctxt, Key>(tcx: Ctxt, kind: K, arg: &Key) -> DepNode<K>
@ -71,7 +71,7 @@ impl<K: DepKind> DepNode<K> {
Key: DepNodeParams<Ctxt>,
{
let hash = arg.to_fingerprint(tcx);
let dep_node = DepNode { kind, hash };
let dep_node = DepNode { kind, hash: PackedFingerprint(hash) };
#[cfg(debug_assertions)]
{

View file

@ -1,4 +1,4 @@
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::QueryInvocationId;
use rustc_data_structures::sharded::{self, Sharded};
@ -976,7 +976,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
// Fingerprint::combine() is faster than sending Fingerprint
// through the StableHasher (at least as long as StableHasher
// is so slow).
hash: self.anon_id_seed.combine(hasher.finish()),
hash: PackedFingerprint(self.anon_id_seed.combine(hasher.finish())),
};
self.intern_node(target_dep_node, task_deps.reads, Fingerprint::ZERO)