4 ms·
I've seen somewhere on the site that Pakyow is "up to 40 some percent faster than Sinatra". What makes Pakyow faster than Sinatra under the hood?
by VeejayRampay 13y ago
I've seen somewhere on the site that Pakyow is "up to 40 some percent faster than Sinatra". What makes Pakyow faster than Sinatra under the hood?
- bryanp 13y agoI can't speak too intelligently about how Sinatra is architected, but here's a bit about how Pakyow handles routing. A route is just a regex and set of functions (blocks, procs, whatever). When a request comes in, the following things happen: 1. An AppContext instance is created that contains the request's state 2. Route is matched (narrowed by method then match on path) 3. Each function is evaluated within the context Hooks, etc aren't special things and are just functions at a particular location in the set. This set is built at startup, so there's no object creation to fulfill a request (except the Request/Response/AppContext objects). The routing bits of pakyow (pakyow-core) are very close to the Rack metal. Aside from routing, nearly everything in Pakyow is middleware. This makes it easy to completely remove (not just disable) components like static file handling, logging, etc. Hope that helps!