Skip to content

Instantly share code, notes, and snippets.

@pi0
Forked from yyx990803/marko-perf.md
Created September 18, 2017 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pi0/db60ae487afdfc5b56b51b95dd9a643e to your computer and use it in GitHub Desktop.
Save pi0/db60ae487afdfc5b56b51b95dd9a643e to your computer and use it in GitHub Desktop.
  • The benchmarks used by Marko, with one benchmark containing only a single component with ~50 lines of code, and the other 3 components with one of them fully static markup, are typical micro-benchmarks created to the advantage of certain implementation details. They are too isolated and too trivial to justify across-the-board performance claims.

  • For client-side performance I recommend using the 3rd party js-framework-benchmark as a more neutral reference; the benchmark tests a much bigger workload and covering a much more comprehensive performance scenarios. According to the data from the latest round Vue actually outperforms Marko. That said, even this benchmark doesn't reflect real world performance where much more overhead comes from big component trees.

  • Vue has significantly improved SSR performance for templates in the 2.4 release, however the server-side benchmark uses a JSX-based setup that doesn't benefit from these improvements. I've created a pull request to use a more idiomatic Vue setup (with single-file *.vue components) which improves Vue's performance by 2x/8x in the two benchmarks. Marko is still far ahead by about 3x, but again the test cases are IMO too trivial to reflect real-world performance. When we were benchmarking Vue's 2.4 SSR improvements in real apps by requests per second, we found the gain to be much less obvious than the 2x we saw in micro-benchmarks, because raw rendering only constitutes a relatively small portion of the time spent in a full server request.

    One additional note regarding Vue 2.4 SSR improvements: although still using vdom under the hood, the template compiler now analyzes the template statically and extract as much as possible into string concatenations (similar to Marko). However, Vue's rendering is "hybrid" in that non-extracted parts still work seamlessly with vdom, i.e. you can still use render functions in logical components where you need the full power of JavaScript, they will seamlessly blend-in with optimized strings around them. In comparison, Marko is limited to "templates only". This hybrid mode is the reason why Vue is not as fast as Marko, but we feel that the ability to use render functions when needed is too important to give up.

The point here is that micro benchmarks are not really good references for real world performance, drawing the conclusion that "Marko is 10x faster than X" from two microbenchmarks is, unfortunately, very misleading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment