Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 24 Mar 2013 11:34:48 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: question about -falign

On Sun, Mar 24, 2013 at 02:25:26PM +0400, michikaze wrote:
> Hello. I'm reading configure script for musl, and those lines
> confused me. Ain't disabling alignment actually hurts performance
> more?
> 
> #
> # Some optimization levels add bloated alignment that hurt performance
> #
> tryflag CFLAGS_AUTO -falign-functions=1
> tryflag CFLAGS_AUTO -falign-labels=1
> tryflag CFLAGS_AUTO -falign-loops=1
> tryflag CFLAGS_AUTO -falign-jumps=1

I haven't seen any good evidence that alignment makes code faster in
practice. The only type of situation where it should help even in
theory is when your loop is so big it barely fits in the instruction
cache, and where misaligning it with respect to cache lines would make
it spill over into an extra cache line and no longer fit. Anyone
hoping for such a bloated function to be fast is on crack.

On the other hand, the way alignment hurts is by adding unused space
all over the place, wasting a significant portion of each instruction
cache line on code that does nothing or that's never run. This waste
is unlikely to show up in micro-benchmarks (where the code all easily
fits in l1 cache) but in large programs will end up evicting other
potentially-performance-critical code from the cache.

Unless anyone can explain to me why the above reasoning is wrong, my
view is that alignment is just harmful.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.