aantron / dream

Tidy, feature-complete Web framework
https://aantron.github.io/dream/
MIT License
1.6k stars 129 forks source link

Optimizations #20

Open aantron opened 3 years ago

aantron commented 3 years ago

Of course, everything should be measured first.

Some early notes from a few weeks ago:

  - request-id seems to take ~3 us.
  - catch ~1 us or less.
  - in-memory sessions 200 us on miss, 100 us on hit.
  - Initial form parser 9 us on tiny input; 30 us on larger, more realistic input
  - jwto CSRF tokens maybe 50 us.
anuragsoni commented 3 years ago

use a trie or a DFA instead of walking through all routes using CPS.

I experimented with this a lot when looking at routing implementation for routes. At the moment tries seemed like the most ideal approach when factoring in ease of implementation/maintenance (compared to dfa construction), and they allowed for easy composition of multiple routers. I also think tries will be fast enough for the vast majority of web applications and will probably have a more predictable memory usage as opposed to a dfa based solution.

dinosaure commented 3 years ago

If you want a fast trie, you should take a look on art which is a fast implementation of an Adaptive Radix Tree.