Skip to content

feat(benchmarks): add GasTrace qualitative gas profiler - #33

Merged
vobradovich merged 6 commits into
masterfrom
feat/gas-trace
Jun 17, 2026
Merged

vobradovich merged 6 commits into
masterfrom
feat/gas-trace

Conversation

@ukint-vs

Copy link
Copy Markdown
Member

Summary

Adds GasTrace — a reply-linked message-tree reconstructor for gtest::BlockRunResult — to awesome-sails-benchmarks. It is the qualitative counterpart to the existing MeasureGas / BenchStorage quantitative tools: where MeasureGas answers how much gas?, GasTrace answers where did the gas go?

  • GasTrace builder merges logs and gas_burned across one or more blocks, groups replies by reply_to, surfaces events as top-level entries, and renders a gas-annotated ASCII tree via Display.
  • MethodRegistry resolves (InterfaceId, entry_id) pairs back to Service::method names using ServiceMeta::{INTERFACE_ID, METHODS}.
  • gtest's block.log() surfaces replies and events but not the originating request — GasTrace synthesizes a root for any gas_burned entry whose id isn't represented in the tree and nests its reply under it, so gas attribution isn't silently dropped.
  • Gated on the existing gtest feature — zero impact when disabled.

Example output

[0x1001..abcd] alice -> MyProgram::MyService::increment  12,400 gas
  `-- [0x1002..9876] [reply] Ok  - gas
[event] MyProgram
Total: 12,400 gas | 3 messages | depth 1

Limitations (documented)

Cross-program sub-calls (A → B → C) appear as separate roots because gtest::CoreLog doesn't expose parent-message causality. This is a gtest runtime constraint, not a tool design choice.

Base branch

Based on feat/awesome-sails-beta (which bumps to sails-rs = 1.0.0-beta.3) — gas_trace needs SailsMessageHeader, InterfaceId, MethodMetadata, ServiceMeta::{INTERFACE_ID, METHODS}, all of which are first published in the 1.0 beta line.

Test plan

  • cargo check -p awesome-sails-benchmarks (default features)
  • cargo check -p awesome-sails-benchmarks --no-default-features (gating verified)
  • cargo check -p awesome-sails-benchmarks --features cli (bench-analyzer still builds)
  • cargo test -p awesome-sails-benchmarks trace::tests — 16/16 unit tests pass
  • cargo test --release -p awesome-sails-benchmarks -- --include-ignored — 27/27 pass (incl. integration demo against access-control-test-app)
  • cargo clippy -p awesome-sails-benchmarks --all-targets --all-features -- -D warnings — clean
  • cargo fmt --all --check — clean

🤖 Generated with Claude Code

m62624 and others added 4 commits April 3, 2026 10:45
Adds a reply-linked message tree reconstructor for `gtest::BlockRunResult`
to complement the existing quantitative `MeasureGas` / `BenchStorage` tools.

- `GasTrace` builder merges logs and `gas_burned` across one or more blocks,
  groups replies by `reply_to`, surfaces events as top-level, and renders a
  gas-annotated ASCII tree via `Display`.
- `MethodRegistry` resolves `(InterfaceId, entry_id)` pairs back to
  `Service::method` names using `ServiceMeta::{INTERFACE_ID, METHODS}`.
- gtest's `block.log()` surfaces replies and events but not the originating
  request — `GasTrace` synthesizes a root for any `gas_burned` entry whose
  id isn't represented in the tree and nests its reply under it, so gas
  attribution isn't silently dropped.
- Gated on the existing `gtest` feature (no impact when disabled).
- 16 unit tests (registry, tree reconstruction, display formatting, edge
  cases) + 1 end-to-end integration demo against `access-control-test-app`.

Limitation documented in `GasTrace` rustdoc + README: cross-program
sub-calls (A -> B -> C) appear as separate roots because `gtest::CoreLog`
doesn't expose parent-message causality.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the feat label Apr 16, 2026
@vobradovich
vobradovich changed the base branch from feat/awesome-sails-beta to master June 17, 2026 12:31
@vobradovich
vobradovich self-requested a review June 17, 2026 13:09
@vobradovich
vobradovich merged commit 42ed5a8 into master Jun 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants