I had a brain fart about http routing and how it could be implemented. Let me state upfront that there is nothing wrong with how it’s implemented in ktor, it’s by no means a reaction to the current implementation. It just really about the idea.
I wanted a way of registering routes in thread safe manner, easy api, blazingly fast lookups and avoid as much garbage as possible during lookups. The rudimentary implementation of this idea can be found here
https://github.com/mplatvoet/routes/blob/master/projects/routes/src/test/kotlin/example/performance.kt
It’s by no means a full version (yet), the only thing implemented are paths including wildcard matches. Query paramaters and that kind of stuff not yet but I have a pretty good idea how to do that.
I like the performance results for now. In a single threaded lookup setup (more threads, matching cores, will just be faster in this case) 1 lookup in a table with 100,000 route entries (which of course far more than most apps) takes about 0.001ms (on a macbook pro).