Skip to content

Conversation

romange
Copy link
Collaborator

@romange romange commented Mar 22, 2025

Before: slot merging/splitting logic was mixed with business logic. Also, slots were represented as dictionary, which made the code less readable. Now, SlotRange handles the low-level logic, which makes the high-level code simpler to understand.

@romange romange requested a review from BorysTheDev March 22, 2025 19:54
@romange romange force-pushed the Pr2 branch 2 times, most recently from b83be3c to 920d1ad Compare March 22, 2025 19:57
Before: slot merging/splitting logic was mixed with business logic.
Also, slots were represented as dictionary, which made the code less readable.
Now, SlotRange handles the low-level logic, which makes the high-level code simpler
to understand.

Signed-off-by: Roman Gershman <[email protected]>
Comment on lines +104 to +114
def split(self, slot_id):
assert self.contains(slot_id)

if self.start < self.end:
if slot_id == self.start:
return None, SlotRange(self.start + 1, self.end)
elif slot_id == self.end:
return SlotRange(self.start, self.end - 1), None
elif self.start < slot_id < self.end:
return SlotRange(self.start, slot_id - 1), SlotRange(slot_id + 1, self.end)
return None, None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to rename it because we remove the slot and return the left and right range.
Maybe simple remove_slot_id() is enough or at least add a comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will rename if in subsequent PR. My goal is to add the "drop" action to drop slot ranges ( to reproduce flush slots flow).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And once you drop/flush you can measure :) Nice!

@romange romange merged commit 72fb256 into main Mar 23, 2025
10 checks passed
@romange romange deleted the Pr2 branch March 23, 2025 06:41
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.

3 participants