[swift-server-dev] Proposal: Structs in place of a request-handling function

Cory Benfield cbenfield at apple.com
Mon Dec 11 04:48:30 CST 2017

> On 11 Dec 2017, at 01:27, George Leontiev via swift-server-dev <swift-server-dev at swift.org> wrote:
> I have been thinking recently about how Swift can be used to enable type-safe codebases for servers with high performance requirements. I’ve prototyped some of my ideas here: https://github.com/GeorgeLyon/Server <https://github.com/GeorgeLyon/Server> (for an example see https://github.com/GeorgeLyon/Server/blob/master/Sources/Server/main.swift <https://github.com/GeorgeLyon/Server/blob/master/Sources/Server/main.swift>)
> The main difference between my implementation and swift-server/http is that all of my request handlers are structs which the Server owns and mutates as data comes in. Eventually, this can enable a model with zero allocations per request. In addition, having the server own the memory that the request handlers use enable optimizations based on cache locality.

I assume when you say “zero allocations per request” you mean “zero allocations of application data per request”, as we are presumably allocating some memory to process the HTTP.

Otherwise this design seems completely reasonable: using structures instead of closures is definitely a perfectly valid approach. I’m +0: there are benefits and costs to either model, and so don’t object to either design.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-server-dev/attachments/20171211/70c7dd13/attachment.html>

More information about the swift-server-dev mailing list