Company
Date Published
Author
Andrew Lamb
Word count
1907
Language
English
Hacker News points
None

Summary

This article discusses the use of Tokio, a Rust runtime, for CPU-heavy tasks beyond its traditional use in network I/O. The author argues that while Tokio was initially thought to be unsuitable for such tasks due to potential performance issues, it can actually be a good choice when used correctly. The main points include: Tokio's work-stealing scheduler and language support for continuations (async/await) make it well-suited for CPU-bound tasks; the runtime's overhead can be amortized using vectorized processing; however, common objections to using Tokio include its potential impact on request tail latencies and high per-task overhead. To overcome these issues, the author proposes running tasks on a separate Tokio Runtime instance, which allows for better cache locality and avoids the overhead of the main runtime. The code example demonstrates how to create and use such a dedicated executor.