Skip to content

Commit caf4fc3

Browse files
authored
chore: add more tracing data (#9994)
1 parent 530a220 commit caf4fc3

File tree

10 files changed

+17
-12
lines changed

10 files changed

+17
-12
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,7 @@ diff_output
234234
/website/doc_build
235235

236236
# xcode trace
237-
*.trace
237+
*.trace
238+
239+
# rspack trace file
240+
trace.json

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"rust-analyzer.linkedProjects": [
2222
"Cargo.toml"
2323
],
24+
"rust-analyzer.cargo.features": ["rspack_cacheable/noop"],
2425
"files.associations": {
2526
"*.snap": "markdown",
2627
"*.snap.txt": "markdown",

crates/rspack_core/src/chunk_graph/chunk_graph_module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl ChunkGraph {
283283
.map(|cgm| &cgm.chunks)
284284
}
285285

286-
#[instrument("chunk_graph:get_module_graph_hash", skip_all, fields(module = ?module.identifier()))]
286+
#[instrument("chunk_graph:get_module_graph_hash", level="trace",skip_all, fields(module = ?module.identifier()))]
287287
pub fn get_module_graph_hash(
288288
&self,
289289
module: &dyn Module,

crates/rspack_core/src/compiler/compilation.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ impl Compilation {
14081408
.compilation_hooks
14091409
.optimize_dependencies
14101410
.call(self)
1411+
.instrument(info_span!("Compilation:optimize_dependencies"))
14111412
.await?,
14121413
Some(true)
14131414
) {}
@@ -1445,10 +1446,8 @@ impl Compilation {
14451446
.instrument(info_span!("Compilation:after_optimize_modules"))
14461447
.await?;
14471448
while matches!(
1448-
plugin_driver
1449-
.compilation_hooks
1450-
.optimize_chunks
1451-
.call(self)
1449+
tracing::info_span!("Compilation:optimize_chunks")
1450+
.in_scope(|| { plugin_driver.compilation_hooks.optimize_chunks.call(self) })
14521451
.await?,
14531452
Some(true)
14541453
) {}

crates/rspack_core/src/compiler/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ pub struct Compiler {
9393
}
9494

9595
impl Compiler {
96-
#[instrument(skip_all)]
9796
#[allow(clippy::too_many_arguments)]
9897
pub fn new(
9998
compiler_path: String,

crates/rspack_core/src/normal_module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl NormalModule {
277277
&mut self.presentational_dependencies
278278
}
279279

280-
#[tracing::instrument("NormalModule:build_hash")]
280+
#[tracing::instrument("NormalModule:build_hash", skip_all)]
281281
fn init_build_hash(
282282
&self,
283283
output_options: &OutputOptions,

crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ fn do_optimize_connection(
833833
(dependency, target_module)
834834
}
835835

836-
#[tracing::instrument(skip_all)]
836+
#[tracing::instrument("can_optimize_connection", level = "trace", skip_all)]
837837
fn can_optimize_connection(
838838
connection: &ModuleGraphConnection,
839839
side_effects_state_map: &IdentifierMap<ConnectionState>,

crates/rspack_plugin_swc_js_minimizer/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,12 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
170170
Regex::new(condition)
171171
.unwrap_or_else(|_| panic!("`{condition}` is invalid extractComments condition"))
172172
});
173-
173+
let enter_span = tracing::Span::current();
174174
compilation
175175
.assets_mut()
176176
.par_iter_mut()
177177
.filter(|(filename, original)| {
178+
// propagate span in rayon to keep parent relation
178179
if !JAVASCRIPT_ASSET_REGEXP.is_match(filename) {
179180
return false
180181
}
@@ -188,6 +189,7 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
188189
true
189190
})
190191
.try_for_each_with(tx,|tx, (filename, original)| -> Result<()> {
192+
let _guard = enter_span.enter();
191193
let filename = filename.split('?').next().expect("Should have filename");
192194
if let Some(original_source) = original.get_source() {
193195
let input = original_source.source().to_string();
@@ -279,7 +281,6 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
279281

280282
Ok(())
281283
})?;
282-
283284
compilation.extend_diagnostics(rx.into_iter().flatten().collect::<Vec<_>>());
284285

285286
// write all extracted comments to assets

crates/rspack_plugin_swc_js_minimizer/src/minify.rs

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use swc_ecma_minifier::{
4040
self,
4141
option::{MinifyOptions, TopLevelOptions},
4242
};
43+
use tracing::instrument;
4344

4445
use crate::{JsMinifyOptions, NormalizedExtractComments, PluginOptions};
4546

@@ -62,6 +63,7 @@ pub fn match_object(obj: &PluginOptions, str: &str) -> bool {
6263
true
6364
}
6465

66+
#[instrument("swc_js_minify",skip_all, fields(filename=filename))]
6567
pub fn minify(
6668
opts: &JsMinifyOptions,
6769
input: String,

crates/rspack_tracing/src/chrome.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ impl<S> Filter<S> for FilterEvent {
4242
_cx: &tracing_subscriber::layer::Context<'_, S>,
4343
) -> bool {
4444
// filter out swc related tracing because it's too much noisy for info level now
45-
!meta.is_event() && !meta.target().contains("swc")
45+
!meta.is_event() && !meta.target().starts_with("swc")
4646
}
4747
}

0 commit comments

Comments
 (0)