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 #22

Merged
merged 8 commits into from
Apr 22, 2024
Merged

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Apr 20, 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

@czarcas7ic czarcas7ic added the S:backport/v24 backport to the osmo-v24/v0.37.4 branch label Apr 20, 2024
@czarcas7ic czarcas7ic changed the title fix: pagination prior to unmarshaling txs perf: TxSearch pagination Apr 21, 2024
@czarcas7ic czarcas7ic merged commit 9311fe7 into osmo/v0.37.4 Apr 22, 2024
17 checks passed
@mergify mergify bot mentioned this pull request Apr 22, 2024
3 tasks
czarcas7ic added a commit that referenced this pull request Apr 22, 2024
…pr-22

perf: TxSearch pagination (backport #22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:backport/v24 backport to the osmo-v24/v0.37.4 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant