stack alignment issues (was: unbelievable benchmark output)

2002-02-03 Thread Alfred Perlstein

* Michal Mertl [EMAIL PROTECTED] [020203 08:17] wrote:
 I wrote a simple program which does this:
 
 gettimeofday
 something (takes several seconds)
 gettimeofday
 print time elapsed
 
 Several runs of the program take about the same time but the time
 changes wildly when the executable is called differently.
 
 ---
 ./xx/xxx
 5 s
 xx/xxx
 9 s
 
 and similar. It holds true on vastly different machines with current and
 stable.
 
 The only thing which I can think of that can be causing this is some
 memory alignment issue.

It sure looks like an alignment issue.  If you print the address
of 'i' and 'j' in the attached program you can see for the fast
case they are aligned to 8 byte boundries, but when it's slow they
are at an address that is a multiple of 4 but not 8.

Not really sure what to make of this, anyone else know how we ought
to fix this?

-Alfred


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: stack alignment issues (was: unbelievable benchmark output)

2002-02-03 Thread Miguel Mendez

On Sun, 3 Feb 2002 08:59:41 -0800
Alfred Perlstein [EMAIL PROTECTED] wrote:

Hi,

 It sure looks like an alignment issue.  If you print the address
 of 'i' and 'j' in the attached program you can see for the fast
 case they are aligned to 8 byte boundries, but when it's slow they
 are at an address that is a multiple of 4 but not 8.

Agreed, my bet is on data alignment.

 
 Not really sure what to make of this, anyone else know how we ought
 to fix this?

Well, you could always malloc() some memory and make sure your data is in an address 
that is multiple of 8. You'll waste some mem but will gain performance. I actually 
haven't tried it on FreeBSD but it's a trick I used to do on the Amiga some years ago.

Cheers,

-- 
Miguel Mendez - [EMAIL PROTECTED]
Public Key :: http://energyhq.homeip.net/files/pubkey.txt
EnergyHQ :: http://energyhq.homeip.net
FreeBSD - The power to serve!

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: stack alignment issues (was: unbelievable benchmark output)

2002-02-03 Thread Dan Nelson

In the last episode (Feb 03), Alfred Perlstein said:
 * Michal Mertl [EMAIL PROTECTED] [020203 08:17] wrote:
  Several runs of the program take about the same time but the time
  changes wildly when the executable is called differently.
  
  The only thing which I can think of that can be causing this is
  some memory alignment issue.
 
 It sure looks like an alignment issue.  If you print the address of
 'i' and 'j' in the attached program you can see for the fast case
 they are aligned to 8 byte boundries, but when it's slow they are at
 an address that is a multiple of 4 but not 8.
 
 Not really sure what to make of this, anyone else know how we ought
 to fix this?

This has actually been an issue for ages, most commonly seen with
doubles.  take a look at the thread at

http://www.freebsd.org/cgi/getmsg.cgi?fetch=393691+0+/usr/local/www/db/text/2000/freebsd-current/2507.freebsd-current

or, easier to read the entire thread:

http://groups.yahoo.com/group/freebsd-current/messages/39583?threaded=1

-- 
Dan Nelson
[EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: stack alignment issues (was: unbelievable benchmark output)

2002-02-03 Thread Greg Shenaut

In message [EMAIL PROTECTED], Dan Nelson cleopede:
In the last episode (Feb 03), Alfred Perlstein said:
 * Michal Mertl [EMAIL PROTECTED] [020203 08:17] wrote:
 Not really sure what to make of this, anyone else know how we ought
 to fix this?

This has actually been an issue for ages, most commonly seen with
doubles.  take a look at the thread at

Has any real world program ever been significantly affected by
this problem?

Greg Shenaut

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message