janl / mustache.js

Minimal templating with {{mustaches}} in JavaScript
https://mustache.github.io
MIT License
16.44k stars 2.4k forks source link

Performance improvements #254

Open mjackson opened 12 years ago

mjackson commented 12 years ago

With the 0.7.0 release I focused primarily on API improvements and stability. We unified the high-level API and simplified some of the inner workings of the library, which is a huge win I think for new users and for encouraging contributions.

As part of this work we removed the use of eval to increase compatibility with JavaScript environments that prohibit its use, such as Android. However, this slowed down the code noticeably. I wasn't too concerned with the slow down for several reasons:

Also, the benchmark I'm using in that jsPerf is a bit silly really. It doesn't test very many of the advanced features of mustache.js, so I can't be sure how accurate those numbers really are in real-world scenarios.

I'd like to focus on bringing performance for the 0.7.1 release back up to par with what we were doing in 0.5.2 (our fastest release to date). There are two major areas I think we can focus on:

What do y'all think? I'm actively looking for contributions in these areas, so anyone with expertise here is more than welcome to chime in. Thanks!

/cc @janl @natevw @cweider

cweider commented 12 years ago

Anyways, ouch, that needs improvement, I’ve a few patches to improve things basically inlining and decomposing the tail recursion*. One thing worth toying with are some automated performance tests to make checking the three steps of lex, generation, and execution easy.

mjackson commented 11 years ago

@cweider Thanks for the suggestions. I've inlined all the rendering functions and put off the slice needed by higher order sections until it's actually needed, which provided some nice gains (look at the master branch vs. 0.7.0). I'm not sure how to go about decomposing the tail recursion though. Can you give me any pointers?