deno icon indicating copy to clipboard operation
deno copied to clipboard

perf(tokio): add improved runtime thread handling - multi cpu

Open j-mendez opened this issue 2 years ago • 1 comments

  • improve multi cpu architecture performance
  • add improved thread runtime performance

-- note

This PR leverages multi-core CPUs and improves the spawn capabilities for operations. By default threads live for 10 seconds after idle which makes sense for re-using the same thread except for applications that can be ran once and exited - non http servers etc.

j-mendez avatar Sep 11 '22 11:09 j-mendez

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 11 '22 11:09 CLAassistant

Thanks for the patch! Do you have some benchmark that demonstrates the improvement?

ry avatar Sep 15 '22 13:09 ry

@ry you are welcome! I can get a benchmark this week. Need to make a minimal demo since the project is private, should be straight forward for the example. Thank you for the JS runtime using Rust!

j-mendez avatar Sep 15 '22 14:09 j-mendez

@ry you are welcome! I can get a benchmark this week. Need to make a minimal demo since the project is private, should be straight forward for the example. Thank you for the JS runtime using Rust!

Busy week - made a little progress on the benchmarks will try to get it done soon. Feel free to take this into other hands if moving too slow!

j-mendez avatar Sep 19 '22 12:09 j-mendez

@ry pardon the delay, I went ahead and attached benchmarks for the runtime changes. Thank you for the patience.

j-mendez avatar Oct 15 '22 12:10 j-mendez

@j-mendez Thank you for the benchmarks. Although none of them are doing anything asynchrnous so it's unlikely that we are measuring spawn / spawn_blocking performance here. A better benchmark would be Deno.writeFile or Deno.readFile which uses spawn_blocking for file read/writes.

littledivy avatar Oct 15 '22 13:10 littledivy

@j-mendez Thank you for the benchmarks. Although none of them are doing anything asynchrnous so it's unlikely that we are measuring spawn / spawn_blocking performance here. A better benchmark would be Deno.writeFile or Deno.readFile which uses spawn_blocking for file read/writes.

You are welcome, I appreciate the lead on the next steps. I am going to see if I can look into that since running the bench at root is a bit harder to track due to the amount of benches ran.

j-mendez avatar Oct 15 '22 13:10 j-mendez

@j-mendez Try this one deno run -A --unstable cli/bench/write_file.js. It tries to write small chunks to /dev/null as fast as possible.

littledivy avatar Oct 15 '22 13:10 littledivy

@j-mendez Try this one deno run -A --unstable cli/bench/write_file.js. It tries to write small chunks to /dev/null as fast as possible.

I attached the logs of the before and after. I noticed afterwards my rust-analyzer ran in between reason for the drastic differences on branch checkouts.

j-mendez avatar Oct 15 '22 14:10 j-mendez

Ran the microbenchmarks again and i see no difference. I'd prefer to stay to the default unless there is a clear perf improvement. Thank you for the PR!

littledivy avatar Jan 15 '23 04:01 littledivy