go-chi / chi

lightweight, idiomatic and composable router for building Go HTTP services
https://go-chi.io
MIT License
18.34k stars 983 forks source link

Add ozzo-routing to benchmarking & steal some ideas from it to make chi faster #312

Closed mvrhov closed 6 years ago

mvrhov commented 6 years ago

I did a quick calculation from their benchmark and they seem to be ~1.6x slower than HttpRouter while providing almost the same functionality as chi. Well the regex matching does seem to be missing from all benchmarks.

https://github.com/go-ozzo/ozzo-routing

pkieltyka commented 6 years ago

thank you @mvrhov but the chi Router's radix implementation took months to write and many more months to refine. It's pretty set in stone and has been quite optimized. I haven't looked into ozzo, but if you have any application-level benchmarks, we can have a look where to optimize Chi further. Chi is quite fast though as you can tell from the benchmarks on a pure-routing basis. The only slower parts of Chi is how context.Context is treated in http.Request when having to create a new context, but this is unavoidable based on the stdlib's implementation of the 'context' and 'net/http'. And ultimately chi will not be the bottleneck of a Web service compared to the application code. thanks for the note.