Skip to content

perf: profile stellar resource budgets#45

Merged
truthixify merged 1 commit into
wraith-protocol:developfrom
Codekill33:main
Jun 1, 2026
Merged

perf: profile stellar resource budgets#45
truthixify merged 1 commit into
wraith-protocol:developfrom
Codekill33:main

Conversation

@Codekill33
Copy link
Copy Markdown

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

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@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! 🚀

Learn more about application limits

@truthixify truthixify changed the base branch from main to develop June 1, 2026 15:20
@truthixify
Copy link
Copy Markdown
Contributor

This is the right shape for a perf baseline. The bench harness in stellar/bench/ is reusable, the table is properly columned across instructions / mem bytes / read+write entries / read+write bytes / event bytes, and the "How to Read the Units" explainer plus the references to Stellar's encyclopedia means a future contributor can pick this up without rebuilding the mental model from scratch.

The name_of optimization (storing the reverse-lookup name directly instead of hashing twice) is concrete and the before/after numbers anchor the win. Nice.

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.

@truthixify truthixify merged commit 02e4cea into wraith-protocol:develop Jun 1, 2026
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.

Soroban resource budget profiling & optimization report

2 participants