roy at panix.com
Wed Mar 5 03:09:17 CET 2014
In article <op.xb75g7ap5079vu at gnudebeest>,
"Rhodri James" <rhodri at wildebst.org.uk> wrote:
> On Tue, 04 Mar 2014 05:24:03 -0000, Chris Angelico <rosuav at gmail.com>
> > Code should look like its intent. Warping it around performance is
> > hardly ever worthwhile.
> That depends. In Python, I'd agree with you; if I'm worrying about
> performance in Python, I'm worrying at the level of the algorithms I'm
> using. In a constrained embedded C environment, which is where I spend
> most of my working life, writing your code so that the compiler chooses
> the right optimisation is critical. Sometimes it matters a great deal to
> me that something like "x *= 5" compiles to a single ARM instruction, or
> that splitting a loop into two to avoid a conditional test will let an
> DSP's optimiser double the speed of a section of code.
Yeah. BTDT. I've stolen the bottom three bits of a pointer for my own
use because I know everything is 64-bit aligned so it's all zeros
anyway. I feel like there must be some organization I should be going
to every month that meets in a church basement and I can get up in front
of the room and say, "Hi, my name is Roy and I'm a C++ hacker", and have
everybody be supportive.
I mostly live in the Python world these days, where I'm firmly in the
camp of, "Stay away from O(n^2) and don't hit the database with
unindexed queries, and you're probably good". But, that's because we
push most of the hard work off onto C and C++ code that is written by
guys who worry about the bottom three bits.
One of those really awesome tools is haproxy. It's just amazing how
fast (and stable) that thing is. It's all written in C. Most of the if
statements are decorated with #pragmas telling the compiler which branch
is the most likely to be taken, so it can optimize better. We need
people like that down in the trenches, so the rest of us can run around
naked in the park with flowers in our hair and not worry about the
bottom three bits any more.
More information about the Python-list