Creator of LLVM, Clang, and Swift Says To Not Write Security Critical Code In C/C++

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 14 14:14:43 PDT 2015


On Tue, Jul 14, 2015 at 01:11:51PM -0700, Walter Bright via Digitalmars-d wrote:
> On 7/14/2015 4:01 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?=
> <ola.fosheim.grostad+dlang at gmail.com>" wrote:
[...]
> >I basically don't care about raw throughput, but latency and meeting
> >real time deadlines. Instrumentation can be useful… but I consider
> >that "debugging".
> 
> I infer from that that you aren't using profilers. I've said before
> and many times that if you're not using a profiler, you aren't getting
> top performance. You just aren't. Just like you aren't going to get an
> efficient airplane shape without wind tunnel tests. Too many
> variables.
[...]

+1. On the same level of evil with premature optimization, is uninformed
optimization. I have experienced this first-hand, where I was absolutely
confident that a particular part of a program was responsible for its
slowness, and that I had already optimized it to death and it just
cannot possibly go any faster.

Until I ran a profiler on it... and then discovered that that part of
the program wasn't even a blip on the radar (after all, I *did* optimize
it to the death already). The *real* bottleneck was somewhere else
completely unexpected -- it was a leftover debugging printf that had
been overlooked and left in an inner loop. A 1-line change sped up the
program (that I thought was already maxed out) by at least 20-30%,
probably more.

Moral: Use a profiler. Don't believe in what you think is the
bottleneck, because you're almost always wrong. Don't believe in your
absolute confidence that the bottleneck must be that ugly bit of code in
object.d. Don't believe what your Finger of Blame tells you is the
bottleneck (in somebody else's code).  Only a profiler will tell you the
true bottleneck. The true bottleneck is almost always somewhere
completely unexpected, and nowhere near where you thought it would be.

The sooner you learn to use a profiler, the less time you'll waste
optimizing things that don't matter while the real bottlenecks continue
to plague your performance.


T

-- 
"The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts." -- Bertrand Russell. "How come he didn't put 'I think' at the end of it?" -- Anonymous


More information about the Digitalmars-d mailing list