Skip to content

[move][tracing] Update tracing to support not generating unneeded values internally for sparse traces#25900

Open
tzakian wants to merge 2 commits intomainfrom
tzakian/sparse-tracing2
Open

[move][tracing] Update tracing to support not generating unneeded values internally for sparse traces#25900
tzakian wants to merge 2 commits intomainfrom
tzakian/sparse-tracing2

Conversation

@tzakian
Copy link
Contributor

@tzakian tzakian commented Mar 19, 2026

Description

This adds wants_effects() to the Tracer trait so the VM tracer can skip expensive value resolution when the tracer will discard effect events and those values are not needed.

When InstructionOnlyTracer or FunctionOnlyTracer is used, the VM tracer was eagerly converting every runtime value into a SerializableMoveValue via into_annotated_move_value which incurred a recursive tree traversal with StructTag/Identifier cloning) for Push/Pop/Read/Write effects — only for those effects to be immediately filtered out by push_event. This is the dominant per-instruction cost in the tracer.

Changes:

  • Add Tracer::wants_effects() -> bool to the trait, and this is set to false by InstructionOnlyTracer and FunctionOnlyTracer
  • Cache the result as wants_effects: bool in VMTracer at construction.
  • In start_instruction_impl: early-return path that skips all value resolution except StLoc side effects (store_global/insert_local) and index capture for VecImmBorrow/VecMutBorrow.
  • In end_instruction_impl: use push_effect! / emit! macros to gate value resolution behind wants_effects, while always performing type-stack management. Write-effect arms (StLoc, WriteRef, VecPushBack, VecSwap) use inline conditionals since their resolution logic is treated in a more special manner.
  • Full tracing is unchanged — other than the bool check per instruction.

The instruction-only trace baselines shrink (no effect events emitted), and full trace baselines see minor changes from the FunctionOnlyTracer's notify fix (which was incorrectly keeping Instruction events). The changes in the instruction only traces is because the trace IDs used for the frame IDs change (because the trace is smaller).

Test plan

Existing tracing tests. This reduces generation of sparse traces


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • Indexing Framework:

@tzakian tzakian requested review from a team, awelc and dariorussi March 19, 2026 22:09
@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sui-docs Ready Ready Preview, Comment Mar 20, 2026 4:43pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multisig-toolkit Ignored Ignored Preview Mar 20, 2026 4:43pm
sui-kiosk Ignored Ignored Preview Mar 20, 2026 4:43pm

Request Review

@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env March 19, 2026 22:09 — with GitHub Actions Inactive
// Macro: resolve stack values as Push effects, or skip if !wants_effects.
// - push_effect!() — resolve the top-of-stack (index 0) as a single Push effect.
// - push_effect!(n) — resolve n stack values as Push effects (in reverse order).
macro_rules! push_effect {
Copy link
Contributor

@cgswords cgswords Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a macro emit_effects! that takes a body and reuse it everywhere.

Also, this macro is weird to see littered in the code below. I think preserving the intent of that code by using some emit_effects! { ... } will help a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Much nicer!

}

/// Skip building effects: clear any captured pre-effects and return empty.
fn skip_effects(&mut self) -> Vec<EF> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we clear them here? I appreciate we are trying to save some work, but generating the pre-effects is work too. We should never run afoul of this in the limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to remove without much issue so good call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants