-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
refactor router #2218
Comments
It's less than 80% now that I've added more compatible behavior, but here's what I currently get with the silly benchmark included with Express: express-optimized1 middleware 5 middleware 10 middleware 15 middleware 20 middleware 30 middleware 50 middleware 100 middleware Express 4.5.01 middleware 5 middleware 10 middleware 15 middleware 20 middleware 30 middleware 50 middleware 100 middleware |
how much of it is just using |
actually nevermind, id on't see any path matching in the benchmarks. |
I'm not calling a url parser at the moment, just doing a simple substring() to separate the path and query string. This obviously affects |
Neat. I'd also be interested in like if you kept a fork of express with your router added into it so I could run the current test suite against it (really, just to know what it does and doesn't do right now). |
The readme describes exactly what is supported. I don't care much to muck around with Express's testing setup :-). |
haha. I also have a question with the benchmark: when it was run against express 4.5.0, I assume it was run against |
The benchmark was ran as-is from the repo. |
It also looks like the handlers are not wrapped in a |
If you have to do a try-catch, you should do it in a separate function that just does a try-catch since v8 will deoptimize the whole function that a try-catch is in. |
Right. Can you add that to your router, perhaps? See how that hits the numbers is all I want (not saying there isn't a way to optimize it, just that it probably makes a difference in those benchmarks is all). |
Adding the try-catch doesn't affect things significantly:
|
So far I'm trying to use your router and doing standard |
We can rip the router stuff out into the routification repo and do perf/bench improvements there. I am all for perf gains as long as feature set is not affected. |
@defunctzombie yes, I agree we should rip the router into a separate repo for sure--I had sort of started doing that a week ago, because I think @jonathanong was talking about we should do that for express 5.x. |
I took a look at the optimized code. IMO it is hard to follow and not well organized. Maybe the lessons learned can be applied to some "slow" router pieces or isolated. I would not favor moving over to that code as is. I realize it may be faster and that is something we can learn from. Optimized code is often less pretty than not, so it might be worth it for some parts but not as a whole. |
We should have the new repo be ready for use before express 5 lands so people can test that out for their router needs. |
@defunctzombie so far it doesn't seem to even work for the most basic apps in our
?? I'm not 100% sure what that means, sorry :) I did want to have a module out that was exactly the express 4.x router, so if express 5.x has different mechanics, people could require a old version of that lib to use the same 4.x-compatible routing. |
It means exactly that. I meant to say they could depend on the router module separately from express core. |
haha, I guess we think similar :) |
Is there a roadmap planned for Express 5? On Mon, Jul 7, 2014 at 10:44 AM, Douglas Christopher Wilson <
|
@hacksparrow not yet. We are working on one just recently :) I don't know if we're going to keep one in the wiki, or just have issues in the issue tracker only yet. I'm also planning a 5.x branch people can start watching and commenting on, etc. |
Either the wiki or the issue tracker should suffice, as long as we have a On Mon, Jul 7, 2014 at 10:47 AM, Douglas Christopher Wilson <
|
@hacksparrow yes. I don't think we want to make changes in the dark here :) A 5.x means something broke and people need to change their stuff. Breaking something should have a good reason and be open for discussion/oversight for some time, haha. |
.
I just started hacking on it this weekend for fun, so I haven't started writing tests yet. It's merely designed to be an experiment whose purpose is to show that Express currently isn't as "insanely fast" as it could/should be. Separating out the router (if possible) is a good idea though. |
Yep, I know it's new and has a lot of missing pieces :) I'm just afraid on what the speed will end up being when the pieces are added in--it's hard to tell how much it'll slow down the router and in the end it could end up being comparable in speed instead of the large difference it is now, idk. |
@mscdex Can you run benchmark in branch https://github.com/visionmedia/express/tree/slim-benchmark on your machine and output the results for express 4.5.1? I noticed that your benchmark was using |
@dougwilson It gives a small bump in performance. |
Cool. By any chance when you get around to it, can you run the benchmark in the latest https://github.com/visionmedia/express/tree/slim-benchmark branch? Sorry I keep asking ya, but I don't have |
@hacksparrow and those interested, there is now a 5.x branch to watch: https://github.com/visionmedia/express/tree/5.x |
This link makes more sense: https://github.com/visionmedia/express/compare/5.x |
@dougwilson I just got a chance to benchmark the
Here is with
One of the things I'd like to see is for an Express "application" to really just be a Router instance. That would go some way in ensuring consistent performance. |
Ooops, the |
The main difference is that if you just use a router, it doesn't add a bunch of implicit middleware, alter the |
Ok, I've updated the previous post with the new results. It looks like performance is starting to get better, however the performance seems to drop quite a bit (compared to |
Charting the data from #2218 (comment) vs #2218 (comment) it looks like they drop at about the same rate to me: Edit: used the wrong chart type the first time by accident :) |
What implicit middleware? @dougwilson What I meant is that the performance diverges pretty quickly after 10 or so middleware. |
The two things in the
How do they differ? |
Two The main difference is the application mounting, which is a historical thing, but still very widely used by other people, mainly because they get the |
@dougwilson See this issue for the kind of thing I'm referring to. |
Um, that issue is for |
That's even more confusing :-) |
The main difference between a |
RE: |
I intend to make both these things at least configurable, because there are reasons people would want them on and reasons people would want them off. Right now you technically can out-out by making dump empty routes, but that's... dumb :D |
💌 |
Now to get |
Yep, though I'm not sure how possible will be, especially since the main difference is the |
@dougwilson what's the status of this now? |
This is an issue that was for using @mscdex 's router, which made the biggest, change that would break a lot of middleware in the community: it choose not to rewrite |
we were planning to do this in v4 but we never got around to it. @mscdex has been working on optimizing it and says he's gotten an 80% improvement so far. i guess this is the repo: https://github.com/mscdex/express-optimized
he says it may not be totally backwards compatible, so we'll see what we can do
The text was updated successfully, but these errors were encountered: