Skip to content

Why is the CPU overhead of tokio tasks significantly higher than that of goroutines? #6257

Answered by Darksonn
Sunshine40 asked this question in Q&A
Discussion options

You must be logged in to vote

A few thoughts:

  • To compare performance of things other than timers, remove timers from the benchmark. That is, you need to change Go to use channels too.
  • Although I misread your channels benchmark, it doesn't do what you think it does either. The while let Ok(i) part of your loop kills the workers when lagged errors occur. And they can occur in your program. In general, if let Ok and while let Ok is almost always wrong due to incorrect error handling. (whereas if let Some/while let Some usually isn't wrong)
  • You are testing this on Windows. Windows is well known to terrible timers, and comparing anything using timers on Windows is almost meaningless, especially if it's something like a we…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@Sunshine40
Comment options

@Darksonn
Comment options

Answer selected by Sunshine40
Comment options

You must be logged in to vote
2 replies
@Darksonn
Comment options

@Sunshine40
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants