Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Re: FreePascal'...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 720 of 811
Post > Topic >>

Re: FreePascal's $PackRecords and alignment

by Marco van de Voort <marcov@[EMAIL PROTECTED] > Feb 21, 2007 at 12:03 PM

On 2007-02-20, Stephen <stephen@[EMAIL PROTECTED]
> wrote:
> I don't quite understand the difference between FreePascal's 
> $PackRecords directive values.
>
> The do***entation says the values can be 1, 2, 4, 16, and C. I 
> understand the default is to align on 2 byte boundaries, and that 1 
> is the same as a 'packed' record, but how do I know exactly when to 
> choose 2, 4, 16, etc.? Are there performance gains if I use a higher 
> alignment value? Is a value of 2 OK to use all the time, regardless 
> of the size of the members of the record?

As far as I got it from a recent discussion with FPC devels:

- packrecords <x> means that a field of size <x> is aligned on a <x> byte
  boundery. 
- A field with a larger size than <x> is also aligned on <x> 
- composed fields (e.g. record in record) are aligned on the alignment of
the record. So a record that has <y> as largest field size is also aligned
  as if it were a field of size <y>, even though the record can be bigger.
- packrecords C says to take the default of C. I believe it
  nowadays also can be 8.
- in 2.1.1+ there is a new directive {$codealign minrecord=x} this forces
   to align to minimally <x> bytes. (so also smaller entities
   are aligned to this)   

Afaik the performance increasements on modern x86 processors are negiable,
because the small speedups are offset by the average datastructure getting
slightly larger (and slower copied/passed by value etc).

So unless you have some specific reason (like some forms of MMX and SSE)
have to be compatible with a layout on disk or are an compiler and
assembler
expert that wants to get the most extreme performance, you can safely
ignore
it for x86.

It is a good custom to write packed records to disk exclusively, because
nearly any compiler can define something similar to a packed record.
 




 5 Posts in Topic:
FreePascal's $PackRecords and alignment
Stephen <stephen@[EMAI  2007-02-21 00:14:14 
Re: FreePascal's $PackRecords and alignment
Marco van de Voort <ma  2007-02-21 12:03:52 
Re: FreePascal's $PackRecords and alignment
Jonas Maebe <Jonas.Mae  2007-02-21 13:36:40 
Re: FreePascal's $PackRecords and alignment
Marco van de Voort <ma  2007-02-21 14:34:29 
Re: FreePascal's $PackRecords and alignment
Jonas Maebe <Jonas.Mae  2007-02-21 13:33:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 0:51:12 CDT 2008.