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

feat: allocate memory quota for SharedBufferBatch in barrier order #15786

Closed
Little-Wallace opened this issue Mar 19, 2024 · 0 comments · Fixed by #15921
Closed

feat: allocate memory quota for SharedBufferBatch in barrier order #15786

Little-Wallace opened this issue Mar 19, 2024 · 0 comments · Fixed by #15921
Assignees
Milestone

Comments

@Little-Wallace
Copy link
Contributor

Little-Wallace commented Mar 19, 2024

Is your feature request related to a problem? Please describe.

When a barrier reaches some actor. it will acquire some quota and write the data of memtable to shared buffer at first. If there are not enough memory quota, this write operation will be blocked and the actor will also be blocked.

Describe the solution you'd like

  • When the memory usage does not exceed 70% of shared buffer memory capacity, allow data of any barrier writing to hummock.
  • When the memory usage exceed 70% of shared buffer memory capacity, only allow the first barrier writing and let actor with larger barrier waiting for notify.

We use two variables to decide whether a request is the first barrier, max_seal_epoch and min_unseal_epoch. Uploader will update max_seal_epoch every time all data of one barrier has written to hummock storage. For example: Currently, max_seal_epoch is 10, while min_unseal_epoch is 11. Then, epoch-11 finish writing and max_seal_epoch update to 11. Then a request with epoch 14 try to allocate some quota, it will succeed because max_seal_epoch == min_unseal_epoch means that there is no first barrier. And this request will set min_unseal_epoch 14 and MemoryLimiter will refuse all requests with epoch larger than 14. But a few minutes later, some request with epoch-12 reaches, it will also get its quota and set min_unseal_epoch 12. Now all requests with epoch-14 will also fail to get quota.

For refused requests, we use a BTreeMap to group them by epoch. When the memory usage of storage is less than 70%, it will notify some request with smallest epoch.

Describe alternatives you've considered

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant