-
Notifications
You must be signed in to change notification settings - Fork 221
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
Template compilation seems slower with 2.0 #407
Comments
Hello @sferencik |
@sferencik, any updates? |
OK, so here's one of the many files that show a 20x slow-down in compilation. I've run this many more times (200x with each of Handlebars 1.10 and 2.0 to increase the confidence) and for this specific file there's a 50x slow-down. https://gist.github.com/sferencik/2e27f55c9439324ef1568d184f1955b1 Specifically, this file:
UPDATE: I've uploaded a new version of the gist. Ran the test again, this time the numbers are not so bad (16x slow-down, instead of 50x):
|
@zjklee I hope this helps. TBH I don't have the time to dig into the slow-down, nor do I have a very good understanding of the differences that 2.0 introduced. This is not urgent, we can live with the slow-down. However, it would be good, for the sake of the project, to try and zoom in on what's going on. If I find time, I may try to create a test that shows this slow-down, and bisect the Handlebars.Net code around the 2.0 release. That would help at least partially, and doesn't require very deep understanding. |
When updating, I also noticed this. It seems that smaller templates (those with fewer handlebar expressions) seem to have an interesting performance decrease. Taking the gist @sferencik provided, I made a very simple benchmark using Benchmark.Net.
changing the number of expressions appears to produce linear compilation time growth until a certain point.
Results:
5 expressions:
10 expressions:
20 expressions:
40 expressions:
80 expressions:
Switching to 1.11.5 and running the exact same process results in: 1 expression:
5 expressions:
10 expressions:
20 expressions:
40 expressions:
80 expressions:
Keep in mind, this appears to only be the case for very simple templates. Templates with partials, block helpers, sub-expressions, etc... appear to compile significantly faster. Was just adding this as further evidence to the claim that v2 is slower; it only appears to be slower to a point. |
I've upgraded to 2.0.3 and it seems the compilation has slowed down about 2x. It's not a big deal, just want to raise this because it doesn't match the expectations.
I have not benchmarked this properly, just timed how much it takes to compile my large repo: the overall time has gone up from 13-15s to 22-31s. I'll try to provide some clearer numbers later.
The text was updated successfully, but these errors were encountered: