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

Improvement: Refactor JSON RPC filters for memory efficiency. #38

Open
ajnavarro opened this issue Apr 22, 2024 · 0 comments
Open

Improvement: Refactor JSON RPC filters for memory efficiency. #38

ajnavarro opened this issue Apr 22, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ajnavarro
Copy link
Collaborator

Description

The JSON RPC filters currently handle incoming data by storing all pending objects in memory, awaiting transmission to the client. This approach leads to significant duplication of elements in memory for each user, which increases the risk of encountering Out-of-Memory (OOM) errors.

To mitigate these issues, I propose the following changes to how data is managed:

  • Rather than storing all filtered objects in memory, maintain only a pointer for each client subscribed to the endpoint. This pointer will indicate the block height last processed for that client.
  • When a client makes a new request, fetch all relevant data entries from the database starting from the block height indicated by the stored pointer.
  • Apply filters to the data only on request.
  • After the data has been transmitted to the client, update the pointer to reflect the most recent block height that has been processed. We can use PebbleDB to store these pointers. This not only ensures durability across indexer restarts but also facilitates atomic updates of pointers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant