Skip to content

Migrate Slots & Keys Optimizations #1217

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

vazois
Copy link
Collaborator

@vazois vazois commented May 22, 2025

This PR adds following optimizations and fixes to migrate operations

  • For both KEYS and SLOTS option, we now use a sketch to avoid keeping track of the actual keys in a dictionary which is expensive.
  • For KEYS option, when using GETKEYSINSLOT instead of scanning from beginning of the lost implicitly keep track of cursor to scan the remaining part of the log.
  • For slots option, allow parallelize the store scan to speedup migration of data.
  • For both SLOTS and KEYS option, ensure that live keys are migrated (see notes).

NOTES:
Keys to be migrated are not known in advance. We have to scan the store log and capture the keys that belong to a specific slot. The problem with regular scanning is that we might miss keys that have been read-copy-updated to tail if we scan a fixed region.
The solution is to ScanCursor(BA, TA) and return all live keys that may exist beyond the TA address.
If we can do that and because we guarantee no new keys could be added beyond TA for the associated slot (because the slot is in MIGRATING state) then we guarantee that no keys are missed during migration.
The algorithm is as follows:

  • Set slot to MIGRATING (guarantees no new keys will be added for that slot but existing keys can be updated)
  • Capture (BA,TA)
  • Build BloomFilter (BF) => BF = ScanCursor(BA, TA)
  • Change state for key set BF[MIGRATING]
  • Send Data by doing another scan. Ensure the scan sends the keys with no versions outside (BA,TA) boundary. Keep an overflow list for keys that have been updated beyond the TA address
  • Send the keys from the overflow buffer (keys that have been updated.
  • Change state for key set BF[MIGRATED]
  • Repeat until (BA,TA) range has been scanned in full.

@vazois vazois force-pushed the vazois/migrate-optimization branch 4 times, most recently from d2432f6 to be0fc3b Compare May 29, 2025 03:47
@vazois vazois force-pushed the vazois/migrate-optimization branch 4 times, most recently from 7024307 to 1d90f7f Compare June 7, 2025 02:25
@vazois vazois force-pushed the vazois/migrate-optimization branch from 1d90f7f to c64fccc Compare June 11, 2025 17:56
@vazois vazois force-pushed the vazois/migrate-optimization branch from c64fccc to 7641fe6 Compare June 11, 2025 23:12
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.

2 participants