-
-
Notifications
You must be signed in to change notification settings - Fork 30
Thread-safe Buffer.__items__; proper KeysView, ItemsView, ValuesView #93
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two questions regarding the implementation and a few nits.
@@ -165,3 +178,25 @@ def flush(self) -> None: | |||
|
|||
def close(self) -> None: | |||
close(self.fast, self.slow) | |||
|
|||
|
|||
class BufferItemsView(ItemsView[KT, VT]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also override __contains__
in BufferItemsView
to avoid changing the LRU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why __iter__
avoids changing the LRU is because it would raise RuntimeError halfway through. If you're testing if your buffer contains a specific key/value pair, and that causes the value to be unevicted from slow, then I don't see why it should bypass the principle of temporal locality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation; now it makes sense to me. I had assumed we wanted this to be a general property of the views.
If you're testing if your buffer contains a specific key/value pair, and that causes the value to be unevicted from slow, then I don't see why it should bypass the principle of temporal locality.
Sounds good to me!
Co-authored-by: Hendrik Makait <[email protected]>
Co-authored-by: Hendrik Makait <[email protected]>
@hendrikmakait all review comments have been addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @crusaderky!
distributed.worker_state_machine.WorkerStateMachine.validate_state()
, while another is evicting/restoring a key