soroban-rpc: Cache all ledger entries queried from DB in read transaction #845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
As a followup to #837 , also cache all entries queried from the DB in a read transaction.
To have finer control over caching, a new contructor (
NewCachedTx
) has been added. This allows disabling caching in situations in which the cache size could grow out of hand.Why
The preflight library (which in turn depends on rs-env-host) sometimes queries the same entry more than once.
Result
The performance improvement is not huge, but it allows us to be more flexible on the preflight library, not needing to be careful about querying the same entry multiple times.
Also note that the benchmark is pretty naive and doesn't query a lot of ledger entries from the DB.
Before:
After:
Known limitations
N/A