Skip to content

Speed up the slow matching of static routes #11

@nestarz

Description

@nestarz

I came across this PR from Deno's fresh framework that might be beneficial to Rutt.

The PR is a fix to speed up the slow matching of static routes where previously, each static file route had its own URLPattern instance. This approach was slow and did not allow for an exact match.

What the PR proposes is to extend the route pattern to either be URLPattern or string. If the route pattern is a string, they treat it as an exact match, the URL is parsed, and a regex match is avoided. This is only applicable for internally created patterns; user-supplied patterns will still be parsed into URLPattern like before.

The author has reported significant improvements with this fix, reducing route-matching time from 62ms down to 0.7ms in real-world testing.

I think it could be an interesting enhancement for the routing in Rutt as well. It may be worth considering whether similar improvements can be implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions