From 12c084b3db67e8af20802fa5f91be9a1524ee7a1 Mon Sep 17 00:00:00 2001 From: tignear Date: Thu, 29 Oct 2026 12:32:14 +0900 Subject: [PATCH] perf(sv): leave unchanged signatures out of shared discovery tables Each pass of a scope's settle publishes every signature again. Writing an unchanged signature copied the subroutine signature tables whole, since the scope's partial snapshot, which reentrant queries read, shares them. An unchanged signature now leaves the tables alone. Elaborating `uvm_pkg` with `18.12--randomization-of-scope-variables_1.sv` (sv-tests chapter 18), with class structures accepted so that it reaches this discovery, takes 12 s instead of 24 s after #2509, and reports the same diagnostic. Change-Id: Ibeeead8c907b18cc9c9b3a8d416afcf4c8421386 --- .../src/ast/dimensions/discovery.rs | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/crates/celox-sv-analyzer/src/ast/dimensions/discovery.rs b/crates/celox-sv-analyzer/src/ast/dimensions/discovery.rs index 5c942df94e0..858c24d9eba 100644 --- a/crates/celox-sv-analyzer/src/ast/dimensions/discovery.rs +++ b/crates/celox-sv-analyzer/src/ast/dimensions/discovery.rs @@ -832,23 +832,27 @@ fn publish_signature( .iter() .map(|(argument, _)| argument.clone()) .collect::>(); - Arc::make_mut(&mut context.subroutine_param_shapes).insert( - n.clone(), - formals - .iter() - .map(|(_, ty)| procedural::dimensions_from_type(ty)) - .collect(), - ); - Arc::make_mut(&mut context.subroutine_param_names).insert( - n.clone(), - formals - .iter() - .map(|(argument, _)| argument.name.clone()) - .collect(), - ); + // Each pass of a discovery publishes every signature again: an + // unchanged one leaves the tables, which snapshots may share, alone. + let shapes = formals + .iter() + .map(|(_, ty)| procedural::dimensions_from_type(ty)) + .collect::>(); + if context.subroutine_param_shapes.get(&n) != Some(&shapes) { + Arc::make_mut(&mut context.subroutine_param_shapes).insert(n.clone(), shapes); + } + let names = formals + .iter() + .map(|(argument, _)| argument.name.clone()) + .collect::>(); + if context.subroutine_param_names.get(&n) != Some(&names) { + Arc::make_mut(&mut context.subroutine_param_names).insert(n.clone(), names); + } if let Some(ty) = result { let metadata = return_metadata(&tree.state, ty.as_ref(), arguments, context); - context.function_return_types.insert(n, metadata); + if context.function_return_types.get(&n) != Some(&metadata) { + context.function_return_types.insert(n, metadata); + } } } fn local_declaration(