Skip to content

Commit 0330ab6

Browse files
authored
feat: add tracing instrument for persistent cache (#9001)
1 parent 262cf63 commit 0330ab6

File tree

8 files changed

+14
-2
lines changed

8 files changed

+14
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rspack_core/src/cache/persistent/occasion/make/dependencies.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct DependencyRef<'a> {
3838
path: &'a ArcPath,
3939
}
4040

41+
#[tracing::instrument("Cache::Occasion::Make::Dependencies::save", skip_all)]
4142
pub fn save_dependencies_info(
4243
file_dependencies: &FileCounter,
4344
context_dependencies: &FileCounter,
@@ -107,6 +108,7 @@ pub fn save_dependencies_info(
107108
});
108109
}
109110

111+
#[tracing::instrument("Cache::Occasion::Make::Dependencies::recovery", skip_all)]
110112
pub async fn recovery_dependencies_info(
111113
storage: &Arc<dyn Storage>,
112114
) -> Result<(FileCounter, FileCounter, FileCounter, FileCounter)> {

crates/rspack_core/src/cache/persistent/occasion/make/meta.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct MetaRef<'a> {
2929
pub next_dependencies_id: u32,
3030
}
3131

32+
#[tracing::instrument("Cache::Occasion::Make::Meta::save", skip_all)]
3233
pub fn save_meta(
3334
make_failed_dependencies: &HashSet<BuildDependency>,
3435
make_failed_module: &IdentifierSet,
@@ -46,6 +47,7 @@ pub fn save_meta(
4647
);
4748
}
4849

50+
#[tracing::instrument("Cache::Occasion::Make::Meta::recovery", skip_all)]
4951
pub async fn recovery_meta(
5052
storage: &Arc<dyn Storage>,
5153
) -> Result<(HashSet<BuildDependency>, IdentifierSet)> {

crates/rspack_core/src/cache/persistent/occasion/make/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl MakeOccasion {
2020
Self { storage, context }
2121
}
2222

23-
#[tracing::instrument(name = "MakeOccasion::save", skip_all)]
23+
#[tracing::instrument(name = "Cache::Occasion::Make::save", skip_all)]
2424
pub fn save(&self, artifact: &MakeArtifact) {
2525
let MakeArtifact {
2626
// write all of field here to avoid forget to update occasion when add new fields
@@ -61,7 +61,7 @@ impl MakeOccasion {
6161
meta::save_meta(make_failed_dependencies, make_failed_module, &self.storage);
6262
}
6363

64-
#[tracing::instrument(name = "MakeOccasion::recovery", skip_all)]
64+
#[tracing::instrument(name = "Cache::Occasion::Make::recovery", skip_all)]
6565
pub async fn recovery(&self) -> Result<MakeArtifact> {
6666
let mut artifact = MakeArtifact::default();
6767

crates/rspack_core/src/cache/persistent/occasion/make/module_graph.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct NodeRef<'a> {
4949
pub blocks: Vec<&'a AsyncDependenciesBlock>,
5050
}
5151

52+
#[tracing::instrument("Cache::Occasion::Make::ModuleGraph::save", skip_all)]
5253
pub fn save_module_graph(
5354
partial: &ModuleGraphPartial,
5455
revoked_modules: &IdentifierSet,
@@ -123,6 +124,7 @@ pub fn save_module_graph(
123124
}
124125
}
125126

127+
#[tracing::instrument("Cache::Occasion::Make::ModuleGraph::recovery", skip_all)]
126128
pub async fn recovery_module_graph(
127129
storage: &Arc<dyn Storage>,
128130
context: &CacheableContext,

crates/rspack_core/src/cache/persistent/snapshot/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl Snapshot {
3939
}
4040
}
4141

42+
#[tracing::instrument("Cache::Snapshot::add", skip_all)]
4243
pub async fn add(&self, paths: impl Iterator<Item = &Path>) {
4344
let default_strategy = StrategyHelper::compile_time();
4445
let mut helper = StrategyHelper::new(self.fs.clone());
@@ -82,6 +83,7 @@ impl Snapshot {
8283
}
8384
}
8485

86+
#[tracing::instrument("Cache::Snapshot::calc_modified_path", skip_all)]
8587
pub async fn calc_modified_paths(&self) -> Result<(HashSet<ArcPath>, HashSet<ArcPath>)> {
8688
let mut helper = StrategyHelper::new(self.fs.clone());
8789
let mut modified_path = HashSet::default();

crates/rspack_storage/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ rspack_fs = { workspace = true }
2020
rspack_paths = { workspace = true }
2121
rustc-hash = { workspace = true }
2222
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros", "test-util", "parking_lot", "fs"] }
23+
tracing = { workspace = true }
2324

2425
[dev-dependencies]

crates/rspack_storage/src/pack/manager/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ impl ScopeManager {
204204
}
205205
}
206206

207+
#[tracing::instrument("Cache::Storage::update_scopes", skip_all)]
207208
async fn update_scopes(
208209
scopes: &mut ScopeMap,
209210
mut updates: ScopeUpdates,
@@ -243,6 +244,7 @@ async fn update_scopes(
243244
Ok(())
244245
}
245246

247+
#[tracing::instrument("Cache::Storage::save_scopes", skip_all)]
246248
async fn save_scopes(
247249
mut scopes: ScopeMap,
248250
root_meta: &RootMeta,

0 commit comments

Comments
 (0)