refactor(cu-tracker): take explicit instruction name#159
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR makes the CU tracker program-agnostic by replacing
Confidence Score: 4/5The Rust-side refactor is clean and correct, but the workflow change drops The benchmark workflow now omits .github/workflows/benchmark.yml needs Important Files Changed
Sequence DiagramsequenceDiagram
participant Test as Integration Test
participant TH as test_helpers.rs
participant SI as SubscriptionsInstruction
participant CT as cu_tracker.rs
participant FS as cu_report.md
Test->>TH: build_and_send_transaction(litesvm, signers, payer, ix)
TH->>TH: litesvm.send_transaction(tx)
TH->>TH: is_tracking_enabled()?
alt CU_REPORT set
TH->>SI: "from_bytes(&ix.data) → name"
TH->>CT: record_cu(name, meta.compute_units_consumed)
CT->>CT: tracker.record(name, cus)
end
TH-->>Test: TransactionResult
Note over CT,FS: On process exit (dtor)
CT->>CT: compute_stats() → min CUs per instruction
CT->>FS: write_to_file("cu_report.md")
Reviews (9): Last reviewed commit: "ci: drop unused CU prettier-ignore (repo..." | Re-trigger Greptile |
Compute Unit Report
🔺 increase · 🔻 decrease · – unchanged · 🆕 new · 🗑 removed (vs Generated: 2026-06-08 |
46533ea to
0c35900
Compare
Make the CU tracker generic (record_cu(name, cus)) instead of decoding the program instruction enum inside the tracker, so the same module can be shared across program repos. The SubscriptionsInstruction::from_bytes name decode now lives in the build_and_send_transaction test glue. Behavior and the cu_report.md output format are unchanged.
0c35900 to
739a5f0
Compare
Replace the inline gh-api comment step with solana-developers/github-actions/cu-benchmark, which diffs against a committed cu_baseline.md and posts per-instruction deltas.
CU is not deterministic across runs (on-chain ATA find_program_address bump search over random keypair owners), so a committed baseline churns every run. Switch to report-only: commit-baseline off, drop contents:write, remove cu_baseline.md, track Min CUs (most stable single value).
Summary
record_cu(name, cus)instead of decoding the program instruction enum inside the tracker, so the samecu_tracker.rscan be shared across program repos (rewards/escrow/vault).SubscriptionsInstruction::from_bytesname decode into thebuild_and_send_transactiontest glue (the single recording site) — zero call-site churn.cu_report.mdoutput format are unchanged.Why
Part of standardizing CU benchmarking across program repos. The shared reusable GitHub Action consumes the
cu_report.mdtable; the tracker that produces it should be program-agnostic (explicit name) so non-Pinocchio repos can reuse it.Test Plan
cargo check -p tests-subscriptions --testspasses.cargo fmt -p tests-subscriptions --checkclean.CU_REPORT=1 just integration-testrun regenerates the same report (requires the program.so); change is a behavior-equivalent relocation of the name decode.