unjs / h3

⚡️ Minimal H(TTP) framework built for high performance and portability

Home Page:https://h3.unjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve route matching (raw) performance

redbar0n opened this issue · comments

Describe the feature

Hono uses a faster RegExpRouter instead of a Radix Tree based router such as Radix3 which H3 currently uses.

Additional information

  • Would you be willing to help implement this feature?

I appreciate your concern about performance and suggestions.

I invite you to check the radix3 benchmarks and see if the raw matcher responsiveness of 7M ops (on a single core of laptop) is less than of your real world usage expectations that might need an alternative method.

There is also an off-topic discussion in unjs/rou3#58 which I will respond in the future.


Generally regarding performances please consider the main bottleneck in any real world server application is not the core or route matcher but user logic and the composition of utilities in which h3 tries to best at.

We can make small adjustments to radix3 to increase benchmark results for specific route conditions but it is just much lower priority comparing to priorities such as ecosystem compatibility.

Also made unjs/rou3#85 as tracker let's move discussion there.

(if you still believe there are strong reasons h3 usage would significantly be different by opting to a different router, we can definitely come back to this 👍🏼 )

commented

@redbar0n @pi0 you may see hono regex router being faster as the router doesn't parse the params into an object but instead keep it in an array which it can be obtained later by prototype pollution.(c.req.param)

commented

But @medley/router algorithm is still the fastest as of rn, not their implementation though