Skip to content

Commit 4832bce

Browse files
authored
Turbopack: more tracing (#75351)
**View the diff without whitespace changes** Add a few more spans similar to the ones that Next has (I don't know where these gaps come from), there are no gaps in the verbose trace below: `TURBOPACK_TRACING=turbopack`: ![Bildschirmfoto 2025-01-27 um 10 23 01](https://github.com/user-attachments/assets/c06c10b5-ec4c-499d-883f-44e227ef5aa1) `TURBOPACK_TRACING=turbo-tasks`: ![Bildschirmfoto 2025-01-27 um 10 23 16](https://github.com/user-attachments/assets/64a23237-db35-47b4-9d3a-0a717e4b0cd5)
1 parent cc8ab34 commit 4832bce

File tree

2 files changed

+35
-22
lines changed
  • turbopack/crates

2 files changed

+35
-22
lines changed

turbopack/crates/turbopack-cli/src/build/mod.rs

+33-22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{
77

88
use anyhow::{bail, Context, Result};
99
use rustc_hash::FxHashSet;
10+
use tracing::Instrument;
1011
use turbo_rcstr::RcStr;
1112
use turbo_tasks::{
1213
apply_effects, ReadConsistency, ResolvedVc, TransientInstance, TryJoinIterExt, TurboTasks,
@@ -149,7 +150,9 @@ impl TurbopackBuildBuilder {
149150
// Await the result to propagate any errors.
150151
build_result_op.read_strongly_consistent().await?;
151152

152-
apply_effects(build_result_op).await?;
153+
apply_effects(build_result_op)
154+
.instrument(tracing::info_span!("apply effects"))
155+
.await?;
153156

154157
let issue_reporter: Vc<Box<dyn IssueReporter>> =
155158
Vc::upcast(ConsoleUi::new(TransientInstance::new(LogOptions {
@@ -270,26 +273,30 @@ async fn build_internal(
270273

271274
let origin = PlainResolveOrigin::new(asset_context, project_fs.root().join("_".into()));
272275
let project_dir = &project_dir;
273-
let entries = entry_requests
274-
.into_iter()
275-
.map(|request_vc| async move {
276-
let ty = Value::new(ReferenceType::Entry(EntryReferenceSubType::Undefined));
277-
let request = request_vc.await?;
278-
origin
279-
.resolve_asset(request_vc, origin.resolve_options(ty.clone()), ty)
280-
.await?
281-
.first_module()
282-
.await?
283-
.with_context(|| {
284-
format!(
285-
"Unable to resolve entry {} from directory {}.",
286-
request.request().unwrap(),
287-
project_dir
288-
)
289-
})
290-
})
291-
.try_join()
292-
.await?;
276+
let entries = async move {
277+
entry_requests
278+
.into_iter()
279+
.map(|request_vc| async move {
280+
let ty = Value::new(ReferenceType::Entry(EntryReferenceSubType::Undefined));
281+
let request = request_vc.await?;
282+
origin
283+
.resolve_asset(request_vc, origin.resolve_options(ty.clone()), ty)
284+
.await?
285+
.first_module()
286+
.await?
287+
.with_context(|| {
288+
format!(
289+
"Unable to resolve entry {} from directory {}.",
290+
request.request().unwrap(),
291+
project_dir
292+
)
293+
})
294+
})
295+
.try_join()
296+
.await
297+
}
298+
.instrument(tracing::info_span!("resolve entries"))
299+
.await?;
293300

294301
let module_graph =
295302
ModuleGraph::from_modules(Vc::cell(vec![ChunkGroupEntry::Entry(entries.clone())]));
@@ -445,7 +452,11 @@ async fn build_internal(
445452

446453
let mut chunks: FxHashSet<ResolvedVc<Box<dyn OutputAsset>>> = FxHashSet::default();
447454
for chunk_group in entry_chunk_groups {
448-
chunks.extend(&*all_assets_from_entries(*chunk_group).await?);
455+
chunks.extend(
456+
&*async move { all_assets_from_entries(*chunk_group).await }
457+
.instrument(tracing::info_span!("list chunks"))
458+
.await?,
459+
);
449460
}
450461

451462
chunks

turbopack/crates/turbopack-ecmascript/src/minify.rs

+2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ use swc_core::{
1919
transforms::base::fixer::paren_remover,
2020
},
2121
};
22+
use tracing::{instrument, Level};
2223
use turbo_tasks_fs::FileSystemPath;
2324
use turbopack_core::code_builder::{Code, CodeBuilder};
2425

2526
use crate::parse::generate_js_source_map;
2627

28+
#[instrument(level = Level::INFO, skip_all)]
2729
pub fn minify(path: &FileSystemPath, code: &Code, source_maps: bool, mangle: bool) -> Result<Code> {
2830
let source_maps = source_maps
2931
.then(|| code.generate_source_map_ref())

0 commit comments

Comments
 (0)