pub struct DepGraph { /* private fields */ }Implementations§
Source§impl DepGraph
impl DepGraph
Sourcepub fn cached_normalize_key_path(
&self,
path: &Path,
key_root: Option<&Path>,
) -> Arc<str> ⓘ
pub fn cached_normalize_key_path( &self, path: &Path, key_root: Option<&Path>, ) -> Arc<str> ⓘ
Cached version of crate::depgraph::context::normalize_key_path.
Looks up (path, key_root) in path_key_cache. On hit, returns
the cached Arc<str> without re-running the underlying normalization.
On miss, computes via normalize_key_path and inserts (subject to
the PATH_KEY_CACHE_MAX_ENTRIES cap — past the cap, the result is
returned without caching so memory stays bounded).
Issue #550 — the compute_artifact_key hot loop’s per-header
allocation hotspot.
Sourcepub fn register(&self, ctx: CompileContext) -> ContextKey
pub fn register(&self, ctx: CompileContext) -> ContextKey
Register a compilation context. Returns the context key. If the context already exists, returns the existing key.
Sourcepub fn register_with_root_and_salt(
&self,
ctx: CompileContext,
key_root: Option<NormalizedPath>,
worktree_salt: Option<&Path>,
) -> ContextKey
pub fn register_with_root_and_salt( &self, ctx: CompileContext, key_root: Option<NormalizedPath>, worktree_salt: Option<&Path>, ) -> ContextKey
Register a compilation context with an optional key root used to
normalize project-local paths across workspace renames.
Variant of Self::register_with_root that folds an optional
worktree_salt into the context key (issue #474). Used by the
multi-file compile path when keys::requires_worktree_in_key is
true for the unit. Returns only the resulting ContextKey.
pub fn register_with_root( &self, ctx: CompileContext, key_root: Option<NormalizedPath>, ) -> ContextKey
pub fn register_with_root_result( &self, ctx: CompileContext, key_root: Option<NormalizedPath>, ) -> ContextRegistration
Sourcepub fn register_with_root_and_salt_result(
&self,
ctx: CompileContext,
key_root: Option<NormalizedPath>,
worktree_salt: Option<&Path>,
) -> ContextRegistration
pub fn register_with_root_and_salt_result( &self, ctx: CompileContext, key_root: Option<NormalizedPath>, worktree_salt: Option<&Path>, ) -> ContextRegistration
Issue #474: variant of Self::register_with_root_result that folds an
optional worktree_salt into the context key. Used by the C/C++
compile pipeline when keys::requires_worktree_in_key returns true
(PCH builds + MSVC), so the resulting cache entry is scoped to one
worktree and can’t be served to a sibling clone whose embedded
paths would diverge from the artifact’s.
Sourcepub fn register_with_key(
&self,
key: ContextKey,
ctx: CompileContext,
) -> ContextKey
pub fn register_with_key( &self, key: ContextKey, ctx: CompileContext, ) -> ContextKey
Register a compilation context with a precomputed key.
Used for Rustc compilations where the context key is computed from
RustcCompileContext (different domain tag) but the dep_graph stores
a CompileContext with the source file path for freshness checks.
pub fn register_with_key_and_root( &self, key: ContextKey, ctx: CompileContext, key_root: Option<NormalizedPath>, ) -> ContextKey
pub fn register_with_key_and_root_result( &self, key: ContextKey, ctx: CompileContext, key_root: Option<NormalizedPath>, ) -> ContextRegistration
Sourcepub fn register_rustc_with_key_and_root_result(
&self,
key: ContextKey,
ctx: CompileContext,
key_root: Option<NormalizedPath>,
externs: Vec<(String, NormalizedPath)>,
) -> ContextRegistration
pub fn register_rustc_with_key_and_root_result( &self, key: ContextKey, ctx: CompileContext, key_root: Option<NormalizedPath>, externs: Vec<(String, NormalizedPath)>, ) -> ContextRegistration
Register a rustc context with its current --extern file inputs.
Rustc context keys already reduce extern path prefixes to filename identity. The dependency graph keeps the actual extern paths here only for hashing/freshness; artifact keys incorporate them by crate name.
Sourcepub fn is_cold(&self, key: &ContextKey) -> bool
pub fn is_cold(&self, key: &ContextKey) -> bool
Returns true if the context has never been updated (no artifact key).
Used by the server to skip pre-compile hashing on cold contexts where
check_diagnostic would return Cold without examining any hashes.
Sourcepub fn check<F, G>(
&self,
key: &ContextKey,
is_fresh: F,
get_hash: G,
) -> CacheVerdict
pub fn check<F, G>( &self, key: &ContextKey, is_fresh: F, get_hash: G, ) -> CacheVerdict
Check if a compilation can use cached output.
is_fresh is called for each file path. It should query Layer 1
(fscache) and return true if the file has not changed since last
known state.
get_hash retrieves the content hash for a file from Layer 1.
Sourcepub fn check_diagnostic<F, G>(
&self,
key: &ContextKey,
is_fresh: F,
get_hash: G,
) -> (CacheVerdict, String)
pub fn check_diagnostic<F, G>( &self, key: &ContextKey, is_fresh: F, get_hash: G, ) -> (CacheVerdict, String)
Check if a compilation can use cached output, with diagnostic reason.
Same logic as check() but returns a reason string
explaining why the verdict was reached (useful for session logs).
Sourcepub fn try_fast_hit<G>(
&self,
key: &ContextKey,
get_hash: G,
) -> Option<ArtifactKey>
pub fn try_fast_hit<G>( &self, key: &ContextKey, get_hash: G, ) -> Option<ArtifactKey>
Fast-path artifact key check: recompute the key from caller-provided
hashes and compare against the stored key. Returns Some(key) when
they match (common cache-hit case), None otherwise.
Compared to check_diagnostic, this method:
- Uses a shared DashMap read (no write lock)
- Skips redundant per-file journal freshness checks (caller already stat-verified every file during the hash phase)
- Avoids
NormalizedPathclones by working with references into the entry
Call this after hashing and before check_diagnostic. On None,
fall back to the full check_diagnostic for miss-reason diagnostics.
Sourcepub fn update<G>(
&self,
key: &ContextKey,
scan_result: ScanResult,
get_hash: G,
) -> Option<ArtifactKey>
pub fn update<G>( &self, key: &ContextKey, scan_result: ScanResult, get_hash: G, ) -> Option<ArtifactKey>
After a compile (or on cold path), record the full include list.
get_hash retrieves the content hash for a file from Layer 1.
Sourcepub fn invalidate_artifact_keys(&self, evicted_hex: &HashSet<String>) -> usize
pub fn invalidate_artifact_keys(&self, evicted_hex: &HashSet<String>) -> usize
Clear artifact_key on every context whose currently-recorded
artifact key is in evicted_hex. Returns the number of contexts
whose key was cleared.
Issue #680 — eviction-divergence fix. When the disk artifact
GC (evict_disk_artifacts) removes an artifact, the depgraph
contexts that point at the now-evicted key still report
CacheVerdict::Hit { artifact_key } on their next check, which
then surfaces in the daemon log as artifact_not_found and a
wasted recompile (the user observed a 15.7% real hit rate on a
soldr dogfood rebuild that should have been ~99%). Wiring the
disk GC to call this method after each eviction batch keeps the
two stores in agreement: the next check on an evicted context
returns Cold (forcing a clean miss + re-store) instead of a
stale Hit.
Key comparison uses the hex form (ArtifactKey::hash().to_hex())
so callers — which already have the evicted artifacts’ string
keys from the disk eviction pass — do not have to round-trip
through ArtifactKey construction.
last_accessed is intentionally NOT bumped — this is a passive
invalidation, and resetting access time would extend the
context’s trim() lifetime past its disk-evicted artifact.
Sourcepub fn trim(&self, max_age: Duration) -> usize
pub fn trim(&self, max_age: Duration) -> usize
Trim entries not accessed within the given duration. Returns the number of entries removed.
Sourcepub fn stats(&self) -> DepGraphStats
pub fn stats(&self) -> DepGraphStats
Get statistics about the graph.
Sourcepub fn get_state(&self, key: &ContextKey) -> Option<ContextState>
pub fn get_state(&self, key: &ContextKey) -> Option<ContextState>
Get the state of a context entry.
Sourcepub fn state_breakdown(&self) -> (usize, usize, usize)
pub fn state_breakdown(&self) -> (usize, usize, usize)
Count contexts by state. Returned as (cold, warm, stale).
Used by the daemon’s depgraph save / load logging to diagnose
post-save / post-load state distribution — specifically to find
out whether contexts are getting persisted as Warm (so is_cold
returns false after restore, enabling the cache lookup path)
or as Cold (so every warm-side compile takes the cold_skip
branch and misses regardless of artifact-store state).
Sourcepub fn contexts_with_artifact_key(&self) -> usize
pub fn contexts_with_artifact_key(&self) -> usize
Number of contexts whose artifact_key is set. Combined with
state_breakdown() this distinguishes contexts that have a
computed key (a successful prior compile) from contexts that
were registered but never reached a Warm state.
Sourcepub fn get_includes(&self, key: &ContextKey) -> Option<Vec<NormalizedPath>>
pub fn get_includes(&self, key: &ContextKey) -> Option<Vec<NormalizedPath>>
Get the resolved includes for a context.
Sourcepub fn get_rustc_externs(
&self,
key: &ContextKey,
) -> Option<Vec<(String, NormalizedPath)>>
pub fn get_rustc_externs( &self, key: &ContextKey, ) -> Option<Vec<(String, NormalizedPath)>>
Get rustc extern input paths for a context.
Sourcepub fn store_file_includes(
&self,
path: NormalizedPath,
includes: Vec<IncludeDirective>,
)
pub fn store_file_includes( &self, path: NormalizedPath, includes: Vec<IncludeDirective>, )
Store scanned includes for a file (shared file node).
Sourcepub fn get_file_includes(
&self,
path: &NormalizedPath,
) -> Option<Vec<IncludeDirective>>
pub fn get_file_includes( &self, path: &NormalizedPath, ) -> Option<Vec<IncludeDirective>>
Get scanned includes for a file.
Sourcepub fn mark_stale(&self, key: &ContextKey) -> bool
pub fn mark_stale(&self, key: &ContextKey) -> bool
Mark a context as stale, requiring rescan on next check.
Returns true if the context existed and was marked stale.
Sourcepub fn ingest_compile_commands(
&self,
commands: &[CompileCommand],
system_includes: &[NormalizedPath],
) -> Vec<ContextKey>
pub fn ingest_compile_commands( &self, commands: &[CompileCommand], system_includes: &[NormalizedPath], ) -> Vec<ContextKey>
Bulk-populate contexts from parsed compile commands.
For each command, parses the arguments, builds a CompileContext
(merging in the provided system include paths), and registers it.
Returns the context keys for all successfully registered entries.
Source§impl DepGraph
impl DepGraph
Sourcepub fn to_snapshot(&self) -> DepGraphSnapshot
pub fn to_snapshot(&self) -> DepGraphSnapshot
Create a serializable snapshot of the current graph state.
Sourcepub fn from_snapshot(snap: DepGraphSnapshot) -> Self
pub fn from_snapshot(snap: DepGraphSnapshot) -> Self
Reconstruct a DepGraph from a deserialized snapshot.
Source§impl DepGraph
impl DepGraph
Sourcepub fn watch_set(&self) -> WatchSet
pub fn watch_set(&self) -> WatchSet
Compute the set of directories that should be watched.
Includes:
- Parent directories of all resolved include paths (to detect modifications)
- Parent directories of source files (to detect source changes)
- All include search directories from all contexts (to detect new files)
Sourcepub fn check_shadow(&self, new_file: &Path) -> Vec<ContextKey>
pub fn check_shadow(&self, new_file: &Path) -> Vec<ContextKey>
Check if a newly created file shadows any existing resolved include in any context. Returns context keys that should be marked stale.
A shadow occurs when new_file has the same filename as an existing
resolved include, and new_file’s directory appears earlier (higher
priority) in that context’s include search path.
Sourcepub fn check_new_resolve(&self, new_file: &Path) -> Vec<ContextKey>
pub fn check_new_resolve(&self, new_file: &Path) -> Vec<ContextKey>
Check if a newly created file resolves any previously unresolved
#include in any context. Returns affected context keys.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DepGraph
impl !RefUnwindSafe for DepGraph
impl Send for DepGraph
impl Sync for DepGraph
impl Unpin for DepGraph
impl UnsafeUnpin for DepGraph
impl UnwindSafe for DepGraph
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more