Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soroban-rpc: Add getPreflight benchmark and test #692

Merged
merged 7 commits into from
Aug 2, 2023

Conversation

2opremio
Copy link
Contributor

No description provided.

@2opremio
Copy link
Contributor Author

In the current benchmark (which simulates a hello world contract with in-memory ledger entries) I get:

goos: darwin
goarch: arm64
pkg: github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/preflight
BenchmarkGetPreflight
BenchmarkGetPreflight-12    	    7196	    164246 ns/op
PASS

That is, 0.164246 ms per simulation! which seems overly good but maybe possible since the DB is not accessed.

I should now write a test accessing the DB.

@2opremio 2opremio force-pushed the simulate-benchmark branch from b21e6f8 to d3f45b0 Compare August 1, 2023 09:52
@2opremio 2opremio changed the base branch from main to soroban-xdr-next August 1, 2023 09:52
@2opremio 2opremio force-pushed the simulate-benchmark branch 2 times, most recently from f1b14c3 to c117697 Compare August 1, 2023 13:34
@2opremio 2opremio force-pushed the simulate-benchmark branch from c117697 to c8a46f0 Compare August 1, 2023 13:59
@2opremio
Copy link
Contributor Author

2opremio commented Aug 1, 2023

I have added a benchmark using the DB and there is a considerable difference:

goos: darwin
goarch: arm64
pkg: github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/preflight
BenchmarkGetPreflightInMemory
BenchmarkGetPreflightInMemory-12    	    5947	    217767 ns/op
BenchmarkGetPreflightInDB
BenchmarkGetPreflightInDB-12        	    2659	    504930 ns/op
PASS

This indicates we should probably be caching the config entries with a write-through cache.

@2opremio 2opremio changed the title soroban-rpc: Add getPreflight benchmark soroban-rpc: Add getPreflight benchmark and test Aug 1, 2023
@2opremio 2opremio marked this pull request as ready for review August 1, 2023 14:03
@2opremio
Copy link
Contributor Author

2opremio commented Aug 1, 2023

note that the benchmark indicates that, even without caching, the preflight took 0.5 ms vs 0.2 milliseconds. So maybe it's not worth the optimization after all

@2opremio
Copy link
Contributor Author

2opremio commented Aug 1, 2023

@tsachiherman PTAL

@2opremio 2opremio merged commit 0d0af89 into stellar:soroban-xdr-next Aug 2, 2023
@2opremio 2opremio deleted the simulate-benchmark branch August 2, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants