Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > struct padding is slower than struct packing

Reply
Thread Tools

struct padding is slower than struct packing

 
 
glen herrmannsfeldt
Guest
Posts: n/a
 
      05-03-2013
christian.bau <(E-Mail Removed)> wrote:

(snip)

> One thing that annoys me with x86 compilers is that they compile 80
> bit long double to have a size of 16 bytes instead of 10, so one
> megabyte cannot hold 100,000 long doubles but only 62,500. On a modern
> processor, the non-aligned access makes no difference (as far as I can
> measure; but the smaller array sizes reduce bandwidth needs.


Some years ago there were complaints about slow access to double on
odd four byte boundaries. The 80486 was a 32 bit data bus, and so didn't
notice. The MS compilers, and maybe others, put allocated to four byte
boundaries. The the pentium and successors came along with 64 bit data
bus, and things slowed down.

I don't know what the natural alignment is for temporary real.

-- glen
 
Reply With Quote
 
 
 
 
Geoff
Guest
Posts: n/a
 
      05-05-2013
On Sun, 05 May 2013 00:29:52 -0500, Robert Wessel
<(E-Mail Removed)> wrote:

>On Fri, 3 May 2013 21:53:51 +0000 (UTC), glen herrmannsfeldt
><(E-Mail Removed)> wrote:
>
>>Robert Wessel <(E-Mail Removed)> wrote:
>>
>>(snip)
>>
>>> Disk manufacturers have used the "correct" (10**3) meaning for the SI
>>> prefixes mostly forever (IBM's marketing literature for the 3380
>>> mentioned that a string could hold more than "10 billion" bytes,
>>> although they didn't use "GB" in the original literature, they did
>>> later:
>>> http://www-03.ibm.com/ibm/history/ex...age_3380c.html).
>>> Some floppy disk formats, and CD-ROMs (but not DVDs, Blue-Ray, and
>>> other optical media) are the exceptions. It became something of an
>>> issue when consumer disks started getting bigger than a few tens of
>>> megabytes started showing a meaning difference from the "expected"
>>> size.

>>
>>IBM disk drives tend not to use power of two sizes. The track size on
>>the 3330 is 13030 bytes (one block per track).
>>
>>13030*404*19=100018280 bytes per pack. Note that 13030, 404, and 19
>>are all not powers of two. (The 19 track/cylinder is because of the
>>rotational position sensing information on the 20th track.)

>
>
>True, although FBA-style disks don't really either, except that
>whatever the size is in some multiple of 512 or 4096, which is almost
>never (ever?) a power of two.
>
>But the point is that I don't think anyone has ever actually
>documented any hard drive being sold in binary units. 10MB was always
>10 million byte, often plus a smidge. After many iterations (and
>years) on the Wikipedia article, the statement about hard drives was
>changed to unequivocal after absolutely no evidence to the contrary
>was found. If any such usage actually existed (and it could well), it
>was extremely rare.


Actually, what was happening was precisely that they _weren't_ using
powers of two but neglecting to specify that fact.

Memory was sold in units of powers-of-two bytes, as in 1MB = 1,048,576
bytes and it was called one megabyte. Drive manufacturers were taking
advantage of this and rating their drives in 1MB = 1,000,000 bytes,
giving a 10 MB hard drive specification that inflated the expectation
in the customer's mind by implying that it was that much bigger than
it really was. The larger the disk, the greater the discrepancy. They
were using the MB term but not telling you that it didn't stand for
the same MB that memory manufacturers (and everyone else) were using.

Then there's the old formatted vs unformatted specification
controversy.

Then Microsoft comes along and counts bytes in one interface and
counts MB and GB in another interface where 2,446,950,400 bytes
becomes 2.27GB in one display and 2,389,600 kB in another.

 
Reply With Quote
 
 
 
 
Geoff
Guest
Posts: n/a
 
      05-05-2013
On Sun, 05 May 2013 01:50:59 -0500, Robert Wessel
<(E-Mail Removed)> wrote:

>I've never really bought that argument. There is one unambiguously
>correct definition for M (1,000,000), and it is used in a vast number
>of places. Even within computing, M=1,000,000 is used in more
>distinct places than M=1,048,576, although there are a
>disproportionate number of instances of the latter uses. Other than
>memory, M=1,048,576, is basically is *not* used (there are of course a
>few exceptions).


Well, I can't make you buy it. It's ancient history to me now but I
remember many discussions about it in the early or mid-70's.

My electronics engineering background has taught me M = mega =
1,000,000 and I never expected a 2 MegOhm resistor to be 2^20 Ohms but
computer geeks were calling _mega_bytes_ by powers of two and those of
us who knew better had to live with it.

IEEE eventually had to step in and make up abbreviations for powers of
ten vs. powers of two.

http://en.wikipedia.org/wiki/Megabyte


Suffice to say there exist two definitions of mega, 10^6 for the
scientists, engineers and public and 2^20 for the hardware and
software geeks.
 
Reply With Quote
 
glen herrmannsfeldt
Guest
Posts: n/a
 
      05-05-2013
Robert Wessel <(E-Mail Removed)> wrote:

(snip)

> I've never really bought that argument. There is one unambiguously
> correct definition for M (1,000,000), and it is used in a vast number
> of places. Even within computing, M=1,000,000 is used in more
> distinct places than M=1,048,576, although there are a
> disproportionate number of instances of the latter uses. Other than
> memory, M=1,048,576, is basically is *not* used (there are of course a
> few exceptions). Did Intel mislead people when the sold a 100MHz
> processor? Were people really expecting it to run at 104,857,600Hz?
> Or expecting their 19.2kb modems to run 19,660 baud? Or the
> computer's bus..., or disk transfer rate..., or the LAN..., or...?


> This is perhaps an Americanism. Where else* could any non-specialists
> think it's reasonable that M is *not* 1,000,000?


In the S/370 days, I used to wonder if IBM prices processors in $K,
if that was $1000 or $1024.

Well, frequencies were in kHz and MHz before the question of computer
clock speed came up.

In the early years, there were computers with decimal addressing, and so
powers of 10 (or small multiples of powers of 10) capacity.

-- glen
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: HELP! Ping getting slower and slower and slower! Paul Computer Information 2 04-03-2012 05:58 PM
Packing a simple dictionary into a string - extending struct? Jonathan Fine Python 9 06-22-2007 11:26 PM
Packing a list of lists with struct.pack() Panos Laganakos Python 5 04-27-2006 01:15 PM
XPath queries getting slower and slower... Andre Charbonneau Java 0 02-15-2005 05:04 PM
Dialup modem connects at slower and slower speeds Sharon Sharp Computer Support 7 10-13-2004 02:51 PM



Advertisments