-
Notifications
You must be signed in to change notification settings - Fork 635
Description
I suspect there are a lot of inefficiencies in sccache-dist, but let's start with a glaringly obvious one.
We use rouille as our web framework (which looks kind of like a dead project, but that's a separate issue). When rouille starts, we request that it start a server with a thread pool to handle requests:
Requests are handled here after they're received from tiny-http:
tiny-http is the actual web server responsible for serving requests...which also has a thread pool of its own:
Plus a separate thread to actually listen on the socket to accept new connections. So processing a request looks like:
- Get the connection on the listening thread.
- Push something into
tiny-http's task pool. - Some other thread turns it into a proper request.
- Said request gets pushed onto a separate message queue.
- The main thread running
rouillegets notified there's a request. - That request gets bounced into
rouille's thread pool. - Something finally processes that.
- I think we do a similar dance to pass it back (?).
That's four threads involved in handling an HTTP request. That cannot possibly be efficient.
I don't know what the right way to untangle this is; I'm not at all familiar with what are the options in the Rust HTTP world. I have seen noise about Tide which from a cursory glance looks more efficient than the above setup, but I think that would require significant async/await buy-in.