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

Use blocking IO in P2P to avoid short sleeps #2778

Closed
wants to merge 1 commit into from

Conversation

hashmap
Copy link
Contributor

@hashmap hashmap commented Apr 25, 2019

It creates constant CPU load. Instead we create 2 threads - one for
reading, one for writing, both block for 1 second then check stop flag,
if it is not set the process continue.
This approach produces 5-10 times less CPU load, the node without TUI
consumes around 2% CPU on my machine vs 10-30%.
Also some refactoring of connection tracking was done, partially to
simplify the code partially to defeat the borrow checker.

It creates constant CPU load. Instead we create 2 threads - one for
reading, one for writing, both block for 1 second then check stop flag,
if it is not set the process continue.
This approach produces 5-10 times less CPU load, the node without TUI
consumes around 2% CPU on my machine vs 10-30%.
Also some refactoring of connection tracking was done, partially to
simplifu the code partially to defeat the borrow checker
@DavidBurkett
Copy link
Contributor

  1. Was the 10-30% with 5ms timeouts (Increasing thread sleeps for socket listener thread and per-connection threads #2773) or just with 1ms?
  2. How does this affect shutdowns?

hashmap added a commit that referenced this pull request May 3, 2019
Fixes #2799

Also 2 Arc's were replaced by one server's instance.
It is needed for p2p thread management in #2778, currently there is no point where we could store thread handles and join them because thread::join
consume the caller, which is impossible in case of Arc.
@hashmap
Copy link
Contributor Author

hashmap commented May 27, 2019

We merged some parts of this pr already, the last piece is #2855

@hashmap hashmap closed this May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants