Getting tokio to match actix-web performance

That was mostly just a side comment. One concern with an embedded/inline 4k array is the cost to move the host struct will go up as it has to memcpy all that (this assumes optimizer doesn't eliminate the move).

Yeah, this landscape (along with the rest of async I/O) is very much still being painted with broad brushstrokes.

Essentially, yes. If you search for "tokio reform" you'll see a bunch of discussions around the current default tokio setup.

They're probably pathological for the default tokio setup, which is the one using a dedicated reactor thread + threadpool for execution. There's a current_thread module in tokio where you can create a reactor + executor to be the same thread (this was the only mode in the previous tokio version, called tokio_core). Take a look at:

  1. tokio::runtime::current_thread - Rust
  2. tokio::executor::current_thread - Rust

The current_thread executor (#2 there) is what actix-web appears to use on its http worker threads: https://github.com/actix/actix-web/blob/master/src/server/worker.rs#L185. That spawned HttpChannel then does all subsequent I/O with the peer; you can browse the channel code in https://github.com/actix/actix-web/blob/master/src/server/channel.rs

6 Likes