-
Notifications
You must be signed in to change notification settings - Fork 167
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
Remove shared memory from MPFuture, fix minor bugs #317
Conversation
# Conflicts: # hivemind/moe/server/task_pool.py # hivemind/utils/mpfuture.py # tests/test_util_modules.py
|
Codecov Report
@@ Coverage Diff @@
## master #317 +/- ##
==========================================
- Coverage 81.97% 81.95% -0.03%
==========================================
Files 66 66
Lines 5898 5918 +20
==========================================
+ Hits 4835 4850 +15
- Misses 1063 1068 +5
|
Co-authored-by: Max Ryabinin <[email protected]>
Co-authored-by: Max Ryabinin <[email protected]>
Co-authored-by: Max Ryabinin <[email protected]>
Co-authored-by: Max Ryabinin <[email protected]>
…make-mpfuture-great-again
|
||
def _set_event_threadsafe(self): | ||
def _set_event_if_necessary(self): | ||
if self._aio_event is None or self._aio_event.is_set(): |
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.
nit: self._aio_event.is_set()
is not guaranteed to be thread-safe. This check can probably be removed.
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.
decided to keep is_set for performance reasons
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.
[It's thread-safe in the current implementation, and we've agreed that it's hard to imagine that it will stop being thread-safe.]
name=f"{__name__}.BACKEND", | ||
daemon=True, | ||
) | ||
cls._pipe_waiter_thread.start() | ||
|
||
@classmethod | ||
def _process_updates_in_background(cls, receiver_pipe: mp.connection.Connection): | ||
pid = os.getpid() | ||
while True: |
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.
nit: This loop never stops gracefully. Ideally, it would be cool to stop it via a threading.Event
in the __del__
finalizer of the last active future in the current process.
However, graceful shutdown may be out of scope of this PR.
Co-authored-by: Alexander Borzunov <[email protected]>
…make-mpfuture-great-again
self._state_cache[self._state], self._result = base.FINISHED, result | ||
self._send_update(UpdateType.RESULT, result) | ||
self._send_update(MessageType.RESULT, result) | ||
super().set_result(result) |
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.
nit: In Python 3.7, this may raise RuntimeError
(instead of InvalidStateError
) if set_result
is called concurrently inside one process.
This is a minor issue and we've agreed it won't be fixed.
coroutine set_event_threadsafe is never awaited