<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>nostrademons</author><text>&amp;gt; Until very recently, re-rendering with virtual DOM diffing was considered more performant than direct, incremental DOM manipulation. This too, may no longer be true.&lt;p&gt;Actually wasn&amp;#x27;t strictly true even when React came out, but it was true enough with the code that most JS developers actually wrote to lead to a change in dominant JS framework.&lt;p&gt;DOM manipulation even in 2013 used a dirty-bit system.  Calling element.appendChild would be a few pointer swaps and take a couple ns.  However, &lt;i&gt;if you then called any of a number of methods that forced a layout&lt;/i&gt;, it would re-render the whole page at a cost of ~20ms on mobile devices of the day.  These included such common methods as getComputedStyle(), .offsetWidth, .offsetHeight, and many others - there was a list of about 2 dozen.  Most JS apps of the day might have dozens to hundreds of these re-layouts triggered per frame, but the frame budget is only 16.667ms, so that&amp;#x27;s why you had slow animations &amp;amp; responsiveness for mobile web apps of 2013.&lt;p&gt;React didn&amp;#x27;t need a full virtual DOM layer.  It just needed to ensure that all modifications to the DOM happened at once, and no user code ran in-between DOM manipulations within a certain frame.  And sure enough, there are frameworks that actually do this with a much lighter virtual DOM abstraction (see: Preact) and get equal or better performance than React.&lt;p&gt;The lesson for performance tuning is to &lt;i&gt;understand what&amp;#x27;s going on&lt;/i&gt;, don&amp;#x27;t just take benchmarks at face value.  If a call is expensive, sometimes it&amp;#x27;s &lt;i&gt;conditionally&lt;/i&gt; expensive based on other stuff you&amp;#x27;re doing, and there&amp;#x27;s a happy path that&amp;#x27;s much faster.  Learn to leverage the happy paths and minimize the need to do expensive work over and over again, even if the expensive work happens in a layer you don&amp;#x27;t have access to.</text><parent_chain><item><author>hliyan</author><text>Former HFT dev here. Know fundamentals: sources of performance issues = things that eat&amp;#x2F;waste CPU cycles, things that reach too far down the memory hierarchy. Usually the latter. E.g. L2 cache to RAM - order of magnitude slower; RAM to disk: 4+ orders of magnitude slower.&lt;p&gt;Things that eat CPU: iterations, string operations. Things that waste CPU: lock contentions in multi-threaded environments, wait states.&lt;p&gt;You can usually build a lot of the understanding from first principles starting there. Back in the day we had to do this because there wasn&amp;#x27;t much by way of readily available literature on the subject. Actual techniques will depend or evolve based on your choice of platform or version.&lt;p&gt;E.g. 20 years ago, we used to create object pools in C++ at load time to avoid Unix heap locks at runtime. This may no longer be necessary. 15(ish?) years ago, JNI was used when the JVM wasn&amp;#x27;t fast enough for certain stuff. This is no longer necessary. 10 years ago, immutable JS objects were thought to be faster because  the JS runtimes at the time were slower to mutate existing objects than to create new ones. This too, may no longer be true (I haven&amp;#x27;t checked recently). Until very recently, re-rendering with virtual DOM diffing was considered more performant than direct, incremental DOM manipulation. This too, may no longer be true.</text></item></parent_chain></comment><story><title>Ask HN: How can I learn about performance optimization?</title><text>What are some good resources for learning about performance optimization? This is an area that is new to me, but a big part of my new job.</text></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>jimkoen</author><text>Do you guys still buy the beefiest Intel Xeons in order to fit your main application + OS entirely within the L3 cache? There was a CppCon talk from a HFT dev about this 10 years ago.</text><parent_chain><item><author>hliyan</author><text>Former HFT dev here. Know fundamentals: sources of performance issues = things that eat&amp;#x2F;waste CPU cycles, things that reach too far down the memory hierarchy. Usually the latter. E.g. L2 cache to RAM - order of magnitude slower; RAM to disk: 4+ orders of magnitude slower.&lt;p&gt;Things that eat CPU: iterations, string operations. Things that waste CPU: lock contentions in multi-threaded environments, wait states.&lt;p&gt;You can usually build a lot of the understanding from first principles starting there. Back in the day we had to do this because there wasn&amp;#x27;t much by way of readily available literature on the subject. Actual techniques will depend or evolve based on your choice of platform or version.&lt;p&gt;E.g. 20 years ago, we used to create object pools in C++ at load time to avoid Unix heap locks at runtime. This may no longer be necessary. 15(ish?) years ago, JNI was used when the JVM wasn&amp;#x27;t fast enough for certain stuff. This is no longer necessary. 10 years ago, immutable JS objects were thought to be faster because  the JS runtimes at the time were slower to mutate existing objects than to create new ones. This too, may no longer be true (I haven&amp;#x27;t checked recently). Until very recently, re-rendering with virtual DOM diffing was considered more performant than direct, incremental DOM manipulation. This too, may no longer be true.</text></item></parent_chain></comment><story><title>Ask HN: How can I learn about performance optimization?</title><text>What are some good resources for learning about performance optimization? This is an area that is new to me, but a big part of my new job.</text></story>