Skip to content

feat: cache matchers with simple cache #4004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2016

Conversation

alisd23
Copy link
Contributor

@alisd23 alisd23 commented Oct 6, 2016

Cache matchers by key of pattern up to a maximum of 50 matchers. (arbitrary number).

If anyone has a better idea of what number to use for the cache max, let me know.

Relates to issue #3875

@alisd23 alisd23 changed the title feat: cache matchers with LRU cache feat: cache matchers with LRU cache #3875 Oct 6, 2016
@alisd23 alisd23 changed the title feat: cache matchers with LRU cache #3875 feat: cache matchers with LRU cache Oct 6, 2016
@timdorr timdorr added this to the v4.0.0 milestone Oct 6, 2016
@timdorr timdorr added the bug label Oct 6, 2016
@ryanflorence
Copy link
Member

Thanks for the PR :)

This dep adds 5kb to the gzipped build :( That's half the size of the whole lib in the first place, maybe there's a quick use-case specific implementation?

@alisd23
Copy link
Contributor Author

alisd23 commented Oct 6, 2016

Oh wow yeah I didn't think about that. I'll implement a simple cache and remove this lib 👍

@ryanflorence
Copy link
Member

ryanflorence commented Oct 6, 2016

for example, we probably don't need a full-blown LRU cache. Maybe we can just say "hey, we have 5000 things cached, let's stop caching."

How many apps have 5000 routes? And of apps that have dynamic patterns (like the "recursive" example) they'll just get a tiny bit slower, but maybe not even noticeable because how many sub routes are they going to have dynamically? Am I making sense?

How much memory is 10,000 cached matchers? Maybe we cap it there and then see how things shake out in the real world.

@alisd23
Copy link
Contributor Author

alisd23 commented Oct 6, 2016

Yeah I do agree, I can't imagine many apps have more than even 100 unique routes, so this is only potentially solving a very edgy edge-case.

I would say caching like 500 at any time would be more than enough.

But another question is: is any caching necessary at all? How expensive is the pathToRegexp anyway. Surely any savings from skipping that are negligible?

@ryanflorence
Copy link
Member

I don't have any records but i did a little console.time() fiddling and it seemed that a cache would be helpful since these get rendered a lot

@alisd23
Copy link
Contributor Author

alisd23 commented Oct 7, 2016

Fair enough, can't argue with evidence! A simple cache would seem to be the best solution then 👍

@alisd23 alisd23 force-pushed the cache-matchers branch 2 times, most recently from 2643634 to 6904ba5 Compare October 9, 2016 14:01
@alisd23 alisd23 changed the title feat: cache matchers with LRU cache feat: cache matchers with simple cache Oct 10, 2016
@alisd23
Copy link
Contributor Author

alisd23 commented Oct 10, 2016

@ryanflorence thoughts on this simpler cache?

Copy link
Member

@timdorr timdorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍 LGTM

@ryanflorence ryanflorence merged commit 000c5ea into remix-run:v4 Oct 11, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants