tokio-rs / tokio-core

I/O primitives and event loop for async I/O in Rust
Apache License 2.0
638 stars 115 forks source link

cargo update -> CPU at 100% while idle #306

Closed nayato closed 6 years ago

nayato commented 6 years ago

repro: git clone https://github.com/nayato/length-server cargo run -> CPU is at 0% cargo update && cargo run -> CPU is at 100% I'd guess it's related to recent move to reformed tokio but didn't look closer yet.

carllerche commented 6 years ago

Thanks for the report. I'll take a look.

carllerche commented 6 years ago

I pushed a PR to tokio: https://github.com/tokio-rs/tokio/pull/212

With this patch, the server behaves normally. Once you confirm this, I can merge and push out a patch release fixing the issue.

nayato commented 6 years ago

Tried patching tokio to your branch but tokio-core won't compile with it (neither 0.1 nor master):

[dependencies]
...
tokio-core= { git = 'https://github.com/tokio-rs/tokio-core' }#"0.1"
[patch.crates-io]
"tokio" = { git = 'https://github.com/carllerche/tokio.git', branch = "fix-current-thread-turn" }

Errors are:

tokio-core-ec1bf80948dd483b\e1db2bb\src\reactor\mod.rs:306:32
    |
306 |                         .enter(enter)
    |                                ^^^^^ expected struct `tokio_executor::enter::Enter`, found struct `tokio_executor::Enter`
    |
    = note: expected type `&mut tokio_executor::enter::Enter`
               found type `&mut tokio_executor::Enter`
carllerche commented 6 years ago

@nayato it looks like patch has some wonky behavior w/ multiple crates in a single git repo. The following worked for me:

[patch.crates-io]
"tokio" = { git = 'https://github.com/carllerche/tokio.git', branch = "fix-current-thread-turn" }
"tokio-io" = { git = 'https://github.com/carllerche/tokio.git', branch = "fix-current-thread-turn" }
"tokio-reactor" = { git = 'https://github.com/carllerche/tokio.git', branch = "fix-current-thread-turn" }
"tokio-executor" = { git = 'https://github.com/carllerche/tokio.git', branch = "fix-current-thread-turn" }
"tokio-threadpool" = { git = 'https://github.com/carllerche/tokio.git', branch = "fix-current-thread-turn" }
nayato commented 6 years ago

Yes, patch fixes it.

carllerche commented 6 years ago

Closed by tokio-rs/tokio#212

Also, I pushed a release to crates.io w/ the fix.