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

perf: TxSearch pagination (backport #22) #23

Merged
merged 8 commits into from
Apr 22, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Apr 22, 2024

Since moving to faster blocks, Osmosis public RPC nodes have noticed massive RAM spikes, resulting in nodes constantly crashing:

Screenshot 2024-04-20 at 11 25 36 AM

After heap profiling, the issue was clearly coming from TxSearch, showing that it was unmarshaling a huge amount of data.

Screenshot 2024-04-20 at 11 28 29 AM

After looking into the method, the issue is that txSearch retrieves all hashes (filtered by the query condition), but we call Get (and therefore unmarshal) every filtered transaction from the transaction index store, regaurdless whether or not the transactions are within the pagination request. Therefore, if one were to call txSearch on an event that happens on almost every transaction, this causes the node to unmarshal essentially every transaction.

We have all the data we need in the key though to sort the transaction hashes without unmarshaling the transactions at all! This PR filters and sorts the hashes, paginates them, and then only retrieves the transactions that fall in the page being requested.

We have run this patch on two of our RPC nodes, and have seen zero spikes thus far!

Screenshot 2024-04-20 at 11 33 11 AM

PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

This is an automatic backport of pull request #22 done by [Mergify](https://mergify.com).

(cherry picked from commit 70f628c)
(cherry picked from commit cad947c)
(cherry picked from commit d43a3bb)
(cherry picked from commit 55aadba)
(cherry picked from commit 02e8e5a)
(cherry picked from commit 3fe01c5)
@czarcas7ic czarcas7ic merged commit a37806f into osmo-v24/v0.37.4 Apr 22, 2024
16 checks passed
@mergify mergify bot deleted the mergify/bp/osmo-v24/v0.37.4/pr-22 branch April 22, 2024 19:08
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.

1 participant