Thread (11 messages) flat view 11 messages, 4 authors, 2016-06-15

Re: [PATCH 3/2] Avoid unnecessary strlen() calls

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:00

Possibly related (same subject, not in this thread)

Linus Torvalds [off-list ref] wrote:
On Mon, 19 Mar 2007, Shawn O. Pearce wrote:
quoted
DrNick suggested on #git to try flipping the isspace test around.
This is a smaller change and generated the same ~3.60 seconds run
as Dscho's patch.  I like DrNick's version better.  ;-)
For me, the result seems to be in the noise.

It may be due to running on Core 2. It's not very sensitive to 
micro-optimizations like this. It definitely makes sense to test the 
*stable* test first, since that will help branch prediction (the 
"isspace()" test is *not* very predictable), so I don't disagree with the 
patch, but I suspect it depends a lot on the microarchitecture just how 
much it matters.

Do you perhaps have a P4? It has a very bad branch mispredict penalty, so 
putting the predictable branch first could explain the big difference you 
see..
I tested both patches on a PowerPC G4.  (Apple PowerBook, 1.5 GHz)
Running on Mac OS X 10.4.8.

Might be more of a Linux<->Darwin thing; perhaps my isspace is
significantly slower than yours is...  after all my mmap runs
like a PC from the 1980s...  ;-)

-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help