recv() cpu abuse
- Dominant language
- Rust
- Stars
- 846
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Hello. I'm new with Rust. 20 recv() uses 40% cpu on my linux box. Is this a known issue?
```rust
extern crate bus;
use bus::Bus;
use std::sync::{Arc, Mutex};
use std::thread;
use std::io;
fn main() {
let bus: std::sync::Arc>>
= Arc::new(Mutex::new(Bus::new(10)));
for _ in 0..20 {
let mut rxb = bus.clone().lock().unwrap().add_rx();
thread::spawn(move || loop {
let msg = rxb.recv().unwrap();
});
}
io::stdin().read_line(&mut String::new()).unwrap();
}
```
total
```
11909 root 20 0 1029148 1980 1700 S 39.2 0.1 1:01.07 bus_possible_bu
```
per thread
```
11926 root 20 0 1029148 1980 1700 R 2.7 0.1 0:00.19 bus_possible_bu
11927 root 20 0 1029148 1980 1700 R 2.7 0.1 0:00.19 bus_possible_bu
11931 root 20 0 1029148 1980 1700 R 2.7 0.1 0:00.19 bus_possible_bu
```
cpu
```
model name : Intel(R) Core(TM) i3 CPU 540 @ 3.07GHz
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided Rust example on Linux and observing the per-thread CPU use around recv(). Then inspect the bus receiver implementation reached by recv() to determine why idle receivers consume CPU. Done means establishing whether this is expected behavior and documenting or addressing the cause with a reproducible result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100