The day comes when some client tells you:
Well, it happens to everyone
MY SOFTWARE IS NOT SLOW, COLONEL!
What is it doing?
Can it be made faster?
Can you distract the user?
Can you avoid doing some things?
...with all those CPU cycles?
Each second has ~4·109 cycles
Each toolchain has a max efficiency
Node.js: interpreter + compiler
The real problem is that programmers
have spent far too much time
worrying about efficiency
in the wrong places and at the wrong times;
premature optimization is the root of all evil
(or at least most of it) in programming.
— Donald Knuth, computer scientist
... is not written fast
Source: Dan Luu
80% of the effects come
from 20% of the causes
— Vilfredo Pareto, Italian Sociologist*
*Not known for his many catchy quotes
Worry about the most relevant causes
Used in many engineering areas
Can be used recursively!
64% of the effects come
from 4% of the causes
... and the long tail
It’s this simple: if you don’t sample,
you don’t scale.
If you think this is even a controversial statement,
you have never dealt with observability at scale OR you have done it wastefully and poorly.
— Charity Majors, computer engineer
Bring the problem to the laboratory
— Grace Hopper, computer engineer
Time to measure matters
Max resolution depends on measure
Measurement noise can kill you!
There are three gradations of inveracity:
there are lies, there are damned lies
and there are statistics
— Arthur James Balfour, UK Prime Minister
Usually can get any precision desired
Your mileage may vary — wildly!
Handle with care
Once the hot spot is replicated you can optimize it
It is usually harder than solving a regular bug
Work through the layers: interpreter, optimizer...
Until you need to
And even then...
Don't micro-optimize blindly
There are multiple obstacles on any path
Performance work requires perseverance
There are no magic bullets
Results are likely to change
Every V8 version brings changes
Performance varies wildly across versions
Religion is a culture of faith;
science is a culture of doubt.
— Richard Feynman?, physicist.
True Science teaches, above all,
to doubt and to be ignorant.
Miguel de Unamuno, philosopher.