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

fix: the cpuload 100% in case the tcpstream WouldBlock #3029

Merged
merged 3 commits into from
Sep 9, 2019
Merged

fix: the cpuload 100% in case the tcpstream WouldBlock #3029

merged 3 commits into from
Sep 9, 2019

Conversation

garyyu
Copy link
Contributor

@garyyu garyyu commented Sep 7, 2019

Fix #3025

In #2855, we refactored the p2p code to use blocking IO instead of non-blocking, which returns us the dramatically reduced CPU load.

But the Rust TcpStream behavior for blocking mode is not as expected in some cases.

For example, the stream.read_exact() will practically return immediately if the underlined stream would block.

i.e. the so-called WouldBlock error:
Err(Os { code: 35, kind: WouldBlock, message: "Resource temporarily unavailable" })

Then, the p2p poll() will just seamlessly call the stream.read_exact() in the loop, which in result will give us a 100% cpu load at this case.

@garyyu garyyu merged commit 4faac47 into mimblewimble:master Sep 9, 2019
@garyyu garyyu deleted the fix-cpuload branch September 9, 2019 23:56
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.

CPU Running at 100% for nothing
2 participants