Commit fc8b2916 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

put effect tracing behind env var

parent 9a8880be
...@@ -954,7 +954,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -954,7 +954,7 @@ pub async fn analyse_ecmascript_module_internal(
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
static HISTOGRAM: once_cell::sync::Lazy<Option<String>> = static HISTOGRAM: once_cell::sync::Lazy<Option<String>> =
once_cell::sync::Lazy::new(|| std::env::var("JSVALUE_HISTOGRAM").ok()); once_cell::sync::Lazy::new(|| std::env::var("TURBOPACK_JSVALUE_HISTOGRAM").ok());
if let Some(p) = HISTOGRAM.as_ref() if let Some(p) = HISTOGRAM.as_ref()
&& path.path.ends_with(p) && path.path.ends_with(p)
{ {
...@@ -992,8 +992,27 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -992,8 +992,27 @@ pub async fn analyse_ecmascript_module_internal(
} }
} }
let span = tracing::info_span!("effects processing", count = var_graph.effects.len()); let emit_effect_spans = if cfg!(debug_assertions) {
static PRINT_CHUNK_GROUP_INFO: Lazy<bool> =
Lazy::new(|| match std::env::var_os("TURBOPACK_TRACE_EFFECTS") {
Some(v) => v == "1",
None => false,
});
*PRINT_CHUNK_GROUP_INFO
} else {
false
};
macro_rules! effect_trace_span {
($($args:tt)*) => {
if emit_effect_spans {
tracing::trace_span!($($args)*)
} else {
tracing::Span::none()
}
};
}
let span = tracing::info_span!("effects processing", count = var_graph.effects.len());
async { async {
let effects = take(&mut var_graph.effects); let effects = take(&mut var_graph.effects);
...@@ -1057,7 +1076,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1057,7 +1076,7 @@ pub async fn analyse_ecmascript_module_internal(
"unexpected Effect::Unreachable in tracing mode" "unexpected Effect::Unreachable in tracing mode"
); );
let _tracing_span = tracing::trace_span!("handle unreachable").entered(); let _tracing_span = effect_trace_span!("handle unreachable").entered();
analysis analysis
.add_code_gen(Unreachable::new(AstPathRange::StartAfter(start_ast_path))); .add_code_gen(Unreachable::new(AstPathRange::StartAfter(start_ast_path)));
} }
...@@ -1223,7 +1242,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1223,7 +1242,7 @@ pub async fn analyse_ecmascript_module_internal(
} }
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle conditional")) .instrument(effect_trace_span!("handle conditional"))
.await?; .await?;
} }
Effect::Call { Effect::Call {
...@@ -1258,7 +1277,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1258,7 +1277,7 @@ pub async fn analyse_ecmascript_module_internal(
) )
.await .await
} }
.instrument(tracing::trace_span!("handle call")) .instrument(effect_trace_span!("handle call"))
.await?; .await?;
} }
Effect::MemberCall { Effect::MemberCall {
...@@ -1332,7 +1351,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1332,7 +1351,7 @@ pub async fn analyse_ecmascript_module_internal(
} }
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle member call")) .instrument(effect_trace_span!("handle member call"))
.await?; .await?;
} }
Effect::FreeVar { Effect::FreeVar {
...@@ -1364,7 +1383,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1364,7 +1383,7 @@ pub async fn analyse_ecmascript_module_internal(
} }
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle free var")) .instrument(effect_trace_span!("handle free var"))
.await?; .await?;
} }
Effect::Member { Effect::Member {
...@@ -1387,7 +1406,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1387,7 +1406,7 @@ pub async fn analyse_ecmascript_module_internal(
handle_member(&ast_path, obj, prop, span, analysis_state, analysis).await?; handle_member(&ast_path, obj, prop, span, analysis_state, analysis).await?;
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle member")) .instrument(effect_trace_span!("handle member"))
.await?; .await?;
} }
Effect::ImportedBinding { Effect::ImportedBinding {
...@@ -1443,7 +1462,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1443,7 +1462,7 @@ pub async fn analyse_ecmascript_module_internal(
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle imported binding")) .instrument(effect_trace_span!("handle imported binding"))
.await?; .await?;
} }
Effect::TypeOf { Effect::TypeOf {
...@@ -1459,7 +1478,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1459,7 +1478,7 @@ pub async fn analyse_ecmascript_module_internal(
handle_typeof(&ast_path, arg, span, analysis_state, analysis).await?; handle_typeof(&ast_path, arg, span, analysis_state, analysis).await?;
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle typeof")) .instrument(effect_trace_span!("handle typeof"))
.await?; .await?;
} }
Effect::ImportMeta { Effect::ImportMeta {
...@@ -1479,7 +1498,7 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -1479,7 +1498,7 @@ pub async fn analyse_ecmascript_module_internal(
analysis.add_code_gen(ImportMetaRef::new(ast_path.into())); analysis.add_code_gen(ImportMetaRef::new(ast_path.into()));
anyhow::Ok(()) anyhow::Ok(())
} }
.instrument(tracing::trace_span!("handle import meta")) .instrument(effect_trace_span!("handle import meta"))
.await?; .await?;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment