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

Use a single index Results when querying across blocks #1469

Closed
richardartoul opened this issue Mar 17, 2019 · 0 comments
Closed

Use a single index Results when querying across blocks #1469

richardartoul opened this issue Mar 17, 2019 · 0 comments
Assignees
Labels
area:db All issues pertaining to dbnode area:index All issues pertaining to m3ninx and m3db's index P: High T: Memory Utilization T: Optimization T: Perf

Comments

@richardartoul
Copy link
Contributor

Right now, when we query across many index blocks we allocate a results map for each one, run all the queries in parallel for each block filling up the results map, and then we merge all the results maps together at the end. This makes parallelization easy and straightforward, but since many workloads contain many of the same documents in each block, it causes memory utilization to scale linearly with the number of index blocks. This is problematic for queries that return a large number of documents.

Screen Shot 2019-03-17 at 10 21 11 AM

To address this issue, we will use a single index Results which we will push down into all the block queries. That way, each document will only get allocated in memory once regardless of the number of blocks that are being queried. This will significantly improve memory utilization but will make the results map very heavily contended. To address that, instead of acquiring a lock each time to add a single document, we'll use pooled slices to temporarily gather a configurable number of documents together within the block, then acquire the lock once and add them all together as a batch.

This should give us significantly reduced memory utilization without causing too much contention on the lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:db All issues pertaining to dbnode area:index All issues pertaining to m3ninx and m3db's index P: High T: Memory Utilization T: Optimization T: Perf
Projects
None yet
Development

No branches or pull requests

4 participants