-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Performance improvements! #192
Conversation
export function encodeEntities(s) { | ||
if (typeof s !== 'string') s = String(s); | ||
return s.replace(HTML_ENTITY_REG, replaceTag); | ||
return String(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment to summarize our findings from yesterdays quick benchmarking session and why we're going with the replace variant again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always felt that this change was suspicious and could be the root cause of the performance issues I reported previously for versions after 5.1.2.
I plan to deploy a test release next Monday and roll back this part of the change separately from the 5.1.16 version of the code to see if there are still performance issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JimLiu - that benchmark website produces statistically meaningless results. It's not open source (which is a problem), but I looked at the implementation and it's effectively running benchmarks in a tight loop: while(performance.now()-start < 5000) test()
. This makes the order of benchmarks matter, and allows the JS VM to perform cross-benchmark optimizations that can only happen in the specific case of while(1) test()
and never in real code.
The only current benchmarking website that produces statistically meaningful results is ESbench (disclaimer: I maintain it). The reason for this is because it uses the same Benchmark.js (the library that powered JSPerf, built by Matthias Bynens from the V8 team). Benchmark.js performs JIT warmup runs, encapsulates benchmarks in functions that prevent synthetic VM optimizations (like hoisting/inlining of benchmark code), and returns median values with standard deviation.
Here's the benchmarks we use for encodeEntities
on ESBench:
https://esbench.com/bench/5f88af6cb4632100a7dcd414
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Left a few minor comments. Let me know what you think 👍
Some benchmarks, for reference:
https://esbench.com/bench/5f88af6cb4632100a7dcd414