perf: profile stellar resource budgets#45
Conversation
|
@Codekill33 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
This is the right shape for a perf baseline. The bench harness in The The whole point of this baseline is that we can measure the next round of changes against it. Worth flagging in PERF.md: anyone who lands a change to the Stellar contracts should re-run the bench and update the table in the same PR. We can wire that into CI as a non-blocking signal later. Thanks @Codekill33. |
Summary
Adds a reusable Stellar/Soroban resource budget profiling harness and documents baseline measurements for Wraith’s Stellar contracts. Also lands one safe optimization for wraith-names::name_of by storing the reverse lookup name directly instead of storing a name hash and performing a second lookup.
Changes
Added stellar/bench/ harness runnable with:
cargo run -p wraith-stellar-bench
Added stellar/PERF.md with:
Soroban resource unit explanation
Baseline budget table
Current post-optimization table
Top 5 optimization opportunities
Concrete diff suggestions for the top 3
Before/after numbers for the landed optimization
Updated Stellar contract crates to also emit rlib so the bench harness can reuse generated clients.
Optimized wraith-names::name_of reverse lookup:
Before: Reverse(meta_hash) -> name_hash, then load Name(name_hash)
After: Reverse(meta_hash) -> name
Optimization Result
wraith-names name_of hit improved:
Instructions: 50,728 -> 47,042 (-3,686 / -7.3%)
Memory bytes: 5,554 -> 5,383 (-171 / -3.1%)
Read bytes: 476 -> 452 (-24 / -5.0%)
Validation
cargo fmt --all -- --check
cargo test --workspace
cargo run -p wraith-stellar-bench
All passed.
Notes
The harness uses Env::cost_estimate().resources() in the Soroban test environment. These numbers are useful for relative optimization and regression checks, while production fee-setting should still use Soroban RPC simulation.
closes #6