<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 11 Oct 2012, at 13:59, <a href="mailto:dhkblaszyk@zeelandnet.nl">dhkblaszyk@zeelandnet.nl</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">I did some performance tests on win32 and it appears that<br>both packed and unpacked objects and records all show exactly the same<br>performance. Writing the individual variables in a record or object to<br>file takes about 5.5 times longer than writing them at once. If someone<br>wants my test app to run it on other platforms please let me know then I<br>can post the code. I will do more testing later on mac and linux32. I'm<br>interested how win64 and linux64 behave in this respect. So if someone<br>has these architectures please let me know.<span class="Apple-converted-space"> </span><br></span></span></blockquote><div><br></div><div>As mentioned before, it not only depends on the platform, but also on the contents of the object/record. E.g., a badly misaligned double will generally give much worse performance even on Intel.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">This makes me wonder if<br>choosing a proper value for $PACKRECORDS could make my file readable<br>safely on all platforms, only needing to convert the endianess if<br>applicable. This would not force me to do manual padding in my structs.<br>Say I use a value of 16 would that cover all ABI's FPC currently<br>supports?<span class="Apple-converted-space"> </span><br></span></span></blockquote><div><br></div><div>Yes.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">Jonas: do you have an overview of the alignment on all<br>architectures that FPC supports?</span></span></blockquote><div><br></div><div>The information is not just architecture-specific, but also OS-specific (e.g. the alignment of int64 is 4 on Darwin/i386, but 8 on all other i386 platforms). This is defined in the platform ABI documents (application binary interface).</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">Perhaps you could pinpoint where in the<br>compiler this is handled? If appreciated I could make a patch to include<br>this info in the documentation in the future.<span class="Apple-converted-space"> </span><br></span></span></blockquote></div><br><div>It's a combination of tdef.alignment (and its overridden methods in compiler/symdef.pas), tdef.structalignment (idem) and the varalign information in compiler/systems/i_*.pas. And the latter information in turn can be overridden by the programmer with -Oa switch and the {$codealign ...} directive, or is sometimes also adjusted by us when e.g. new data types are introduced, when bugs are found or when support for a new ABI is added that has different requirements (some OSes support multiple ABIs).</div><div><br></div><div>I don't think documenting it in our manual is a good idea. It's not something people should depend on beyond what the official platform ABIs say, and those documents are maintained separately from our manual (and unfortunately seldom have stable URLs that can be referred to).</div><div><br></div><div><br></div><div>Jonas</div></body></html>