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

Speed up P2P client creation #343

Merged
merged 17 commits into from
Aug 3, 2021
Merged

Speed up P2P client creation #343

merged 17 commits into from
Aug 3, 2021

Conversation

dvmazur
Copy link
Collaborator

@dvmazur dvmazur commented Aug 2, 2021

This PR resolves #300 and speeds up the creation of P2P clients by reading the daemon's stdout instead of pinging it repeatedly.

This optimization speeds up running the tests by 35% locally. Here are the benchmarks:
image
image

@codecov
Copy link

codecov bot commented Aug 2, 2021

Codecov Report

Merging #343 (a355c9d) into master (cf3f64a) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #343      +/-   ##
==========================================
+ Coverage   83.33%   83.40%   +0.07%     
==========================================
  Files          66       66              
  Lines        5977     5973       -4     
==========================================
+ Hits         4981     4982       +1     
+ Misses        996      991       -5     
Impacted Files Coverage Δ
hivemind/moe/server/__init__.py 88.31% <100.00%> (ø)
hivemind/p2p/__init__.py 100.00% <100.00%> (ø)
hivemind/p2p/p2p_daemon.py 96.96% <100.00%> (+1.82%) ⬆️
hivemind/utils/networking.py 66.66% <100.00%> (ø)

@dvmazur dvmazur requested a review from borzunov August 2, 2021 16:36
@dvmazur dvmazur marked this pull request as ready for review August 2, 2021 16:36
@borzunov
Copy link
Member

borzunov commented Aug 2, 2021

Fantastic results! 🚀

One more thing to check is how the daemon behave in case of incorrect arguments. Ideally, we'd like to capture the daemon's stderr, read the error message, and convert it to a Python error with this message.

@borzunov borzunov requested a review from justheuristic August 3, 2021 03:34
self._listen_task = None
self._server_stopped = asyncio.Event()
Copy link
Member

Choose a reason for hiding this comment

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

This event is redundant, we can just cancel self._listen_task.


self._listen_task = asyncio.create_task(listen())

async def _stop_listening(self) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Cancelling self._listen_task is enough here. The corresponding code moved to self._terminate() (since it is not async anymore).

Copy link
Member

@borzunov borzunov left a comment

Choose a reason for hiding this comment

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

I approve @deniskamazur's changes, and Denis approves mine as well :)

@borzunov borzunov merged commit ecdc096 into master Aug 3, 2021
@borzunov borzunov deleted the daemon-start branch August 3, 2021 17:19
This was referenced Aug 3, 2021
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.

[Feature Request] Remove active waiting from hivemind.P2P initialization
3 participants