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

optimize AccountIndexIterator to reuse last loaded bin-map item range #4729

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

HaoranYi
Copy link

@HaoranYi HaoranYi commented Jan 31, 2025

Problem

AccountIndexIterator fetches the items from accounts map in batches, when it is configured "sorted". For each batch, it fetch the result from the underlying bin map by loading, filtering and sorting. However, when a batch only partially consumes a bin map, next batch will start loading/filtering/sorting the same bin map from the beginning again.

Imagining that a bin map contains 10K items, each batch size is 1K, then when we return 10 batches, we will be loading/filtering/sorting the bin-map for 10 times. There is a lot of waste.

We should optimize this by caching the bin-map loaded result in the iterator, so that we only load/filter/sort each bin map at most once.

Summary of Changes

Optimize AccountIndexIterator to reuse last loaded bin-map range.

Fixes #

@HaoranYi HaoranYi changed the title optimize AccountIndexIter to reuse last loaded item range optimize AccountIndexIterator to reuse last loaded bin-map item range Jan 31, 2025
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