Slashdot Mirror


Effect of Using 64-bit Pointers?

An anonymous reader queries: "Most 64-bit processors provide a 32-bit mode for compatibility, but 64-bit pointers are becoming essential as systems move beyond 4GB of RAM. Also, the large virtual address space is very useful for several reasons - allowing large files to be memory-mapped, and allowing pages of memory to be remapped without ever requiring the virtual address space to be defragmented. However, 64-bit pointers take up twice as much memory, which immediately affects memory footprint. This is especially an issue on embedded platforms where RAM is at a premium, but even on systems where RAM is plentiful and cheap the extra memory footprint reduces cache performance. Have Slashdot readers done any research into the actual effect of using 64-bit pointers in a 'typical' application? What proportion of a real program's data is actually pointers?"

46 of 164 comments (clear)

  1. easy... by edrugtrader · · Score: 5, Funny

    Have Slashdot readers done any research into the actual effect of using 64-bit pointers in a 'typical' application?

    none whatsoever.

    What proportion of a real program's data is actually pointers?

    none whatsoever.

    oh... i use java.

    --
    MARIJUANA, SHROOMS, X: ONLINE?! - E
    1. Re:easy... by El · · Score: 5, Funny

      Does Java handle datasets larger than 4GBytes, or does it run so slowly that nobody has been able to find out whether or not it handles them? In the underlying implementation, isn't EVERY object actually a pointer?

      --

      "Freedom means freedom for everybody" -- Dick Cheney

    2. Re:easy... by gl4ss · · Score: 5, Insightful

      every object(which is everything apart from your basic int & etc) is a reference, which pretty much is a pointer with a fancy name. as to handling 4gbytes I really don't see why it couldn't, it's just a matter of the vm supporting it anyways(afaik the design, nor the bytecode, limits it).

      however, can you think of any system where you had objects, sets of data, and they weren't (at least underneath) pointers to memory?

      and as to the original subject one poster already said it best: if you really have the need for that extra effort of going 64bit pointers you will probably have the memory to spare, no? anyways it will only be a problem if if the the pointers are big enough in comparision to what they're pointing to.. in which case you should rethink what you're doing anyways probably if you care a squat about memory footprint.. bringing the embedded devices to the discussion at this point is totally pointless but of course cool sounding and slashdot editor catchy.

      bleh I'm no expert anyways.

      --
      world was created 5 seconds before this post as it is.
    3. Re:easy... by Waffle+Iron · · Score: 5, Insightful
      oh... i use java.

      If you'd pay proper attention to Sun's marketing machine, you'd remember that Java uses a just-in-time compiler. What does a compiler do? It turns all of your "object-oriented is the only valid programming paradigm" source code into a big bucket of CPU-specific opcodes, numbers and *pointers*.

      In fact, it will probably have more pointers than the corresponding C or C++ program would have, due to the plethora of tiny objects you're encouraged to spawn. Naturally, the pointer size would match the CPU architecture on which the program is being run and would consume a corresponding number of cache bytes.

    4. Re:easy... by jstarr · · Score: 5, Informative

      Java does not care about memory limits, the JVM does. The stock Sun JVM for x86 machines will address a maximum of 3-4 GiB (dependent on operating system). However, the IBM JVM on an AIX machine has no practical limit and can easily access >16 GiB memory, if available. If a JVM is so designed, there is no reason a Java program can access as much memory as a program written in C.

      I run very large simulations on various platforms, and some of my simulations have to be run on a 64-bit machine because of the memory requirements. Sun's Java forums have several posts asking for various maximum heap (maximum memory accessable) for various platforms and you can find more exact numbers for specific platforms and operating systems there.

      An object is an object, not a pointer. However, objects are accessed through a reference, which in implementation, is typically a pointer.

    5. Re:easy... by Yuioup · · Score: 2, Informative

      That's not true!!

      When you create an object in Java, you are, in a sense, creating a pointer. As a matter of fact it's easy to make a linked list or a binary tree with Java, the same way you do in C. Just because it's not explicitly called a pointer doesn't mean it isn't used.

      Ever heard of a NullPointerException?

      "Java doesn't have pointers" is a hype phrase still left over from the Dot Bomb era...

  2. Embedded 64-Bit by MBCook · · Score: 3, Insightful
    If you were going to build something that used embedded 64 bit processing, why would you choose a processor with a 64 bit address space? If you need that much address space, then chances are you can handle the extra RAM needed by the pointers, right?

    Is this really a problem in the embedded space?

    --
    Comment forecast: Bits of genius surrounded by a sea of mediocrity.
    1. Re:Embedded 64-Bit by PenguinOpus · · Score: 5, Insightful

      You missed a good point in the original question. Even if you have tons of RAM, cache size is not growing as quickly and you will thrash your data cache far more quickly if all your pointers double in size. I don't know if immediate mode addressing instructions are common for 64bit operands but if they are, it could thrash your icache sooner as well.

      Bandwidth from memory to cache will also be used by these larger pointers.

      OTOH, other than disk controller caches (?), what kind of embedded systems need more than 4GB online simultaneously ?

    2. Re:Embedded 64-Bit by Pseudonym · · Score: 5, Informative
      OTOH, other than disk controller caches (?), what kind of embedded systems need more than 4GB online simultaneously?

      There's a lot of modern medical equipment which can definitely use the 4GB. MRI machines, CT scanners, ultrasound machines ("sonographs" if you prefer the term) and so on do tend to chew up memory. Particularly the first two, because you often need to hold whole voxel sets in memory while you compute a bunch of cross-sections at odd angles.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    3. Re:Embedded 64-Bit by Grab · · Score: 4, Insightful

      I'd say this isn't a problem, will never be a problem, and the person who posted that initial question really doesn't know shit about embedded.

      Embedded devices come in all sorts of varieties from 4-bit to 64-bit, and will do for the foreseeable future. When you're producing X million chips, the software is amortised to basically nothing and the hardware cost becomes the primary concern, so there is no chance that lower-spec chips will ever go away in the future.

      So you're not going to be forced to use a 64-bit chip in your design, just because the chip company has stopped selling the lower spec ones. In the PC business this does happen, because there's no demand for older, lower-spec chips. In the embedded market though, the demand is there and will continue to be there, so the situation has not and will not arise.

      If your target application needs 64-bit processing, you choose a device that does 64-bit processing, and you choose RAM size to suit. If you don't need it, you don't choose it. Simple.

      Someone elsewhere had some questions about internal registers/internal RAM. Well as with all processors, some give you enough registers and some don't. Again, the engineer just has to pick the processor that gives the capabilities they want.

      Grab.

    4. Re:Embedded 64-Bit by Scherf · · Score: 2, Interesting

      OTOH, other than disk controller caches (?), what kind of embedded systems need more than 4GB online simultaneously ?

      Some CAD Programms used in Mechanical Engineering (CATIA V5 for example) could use that much. Loading a whole car engine into one of these Programms will exceed 4 GB pretty quickly.

    5. Re:Embedded 64-Bit by j3110 · · Score: 3, Interesting

      I think the cache arguement is complete BS. It appears it would be true, but not really. Most pointers are created and controlled by the compiler, and they are going to be relative 90% of the time. That's why relative addressing was invented. So, you get an extra 4 bytes stuffed into your cache on the relatively rare occurance that one of your 8 byte pointers are being used. In this 8 byte pointer, I'm just going to assume that you aren't idiot enough to be accessing memory in the same page most of the time. I really think that the page switching of the RAM to access the data at the other end of the pointer is going to be the greatest overhead. Normal cache misses in a 64bit addressing scheme should be exponentially more than a 32bit, if you really needed the 64bit.

      So while you may have a caching problem, I think it's going to be because of accessing more data rather than the 4 bytes extra on some pointers.

      Now if you're using disk based data structures, you better be using 64bit. I could make an exception if you used a 32bit number to address the cluster, then a 16bit number to access the actual data in the cluster, if required. A good DB server would do well to use 32bit cluster numbers to save index size, then scan the loaded cluster for the record. AFAIK, no one has been clever enough to do this, but I'm not privy to the internal structures of a lot of DBMSs. And this would matter a lot, because you could fit much more of the index into memory, and have much less data to read on the drive. Throwing away CPU cycles and memory for more compact disk data is a common practice.

      --
      Karma Clown
  3. Embedded platforms?!? by El · · Score: 3, Interesting

    How many embedded devices are running 64-bit processors now? Offhand, I'd say this is only a problem if you have an embedded device with more than 4 GBytes of memory... in other words, it hardly sounds like a real-world problem for embedded devices. Yes, workstations and servers with 64-bit processors should probably be using 64-bit pointers.

    --

    "Freedom means freedom for everybody" -- Dick Cheney

    1. Re:Embedded platforms?!? by MerlynEmrys67 · · Score: 5, Insightful
      Worked on a Xeon based embedded platform that could have 16 GB of Ram on the system board... You forgot that Intel provides a segmented architecture didn't you ?

      By the way, the limit was from physical slots - 8 and a 2GByte DIMM memory limit, increase either of those and guess what.

      Now each "process" on our box could only address 4 Gbyte of that memory, but that was a completely different question (and in fact limited by the libraries that were used - again a different story)

      I remember these conversations when the 32 bit world came around - what do you mean I have to put 4 bytes into the processor. End result is that the code is a little larger, and a little slower - and Moore's law marches on and we don't even notice

      --
      I have mod points and I am not afraid to use them
    2. Re:Embedded platforms?!? by davetm · · Score: 2, Interesting

      Personally, both types of embedded device I've worked on have been 32 bit. The first was a database engine (think network attached storage^H^H^H^H^H^H^Hdatabase of several Terabyte dataset size), and the second is set top boxes for digital tv. In the case of the first I can immediately see the need for 64bit arithmetic AND addressing. In the case of the set top box I think 32 bits will be fine for a while yet; there is pressure for faster processors, but not for 64 bit arithmetic.

      --
      -- Dave
    3. Re:Embedded platforms?!? by addaon · · Score: 3, Interesting

      Many 32 bit platforms, including x86, PowerPC, etc, support 64GB of ram... but only 4GB of address space. Most people want more than 4GB of address space, but don't yet care about more than 4GB of ram.

      --

      I've had this sig for three days.
    4. Re:Embedded platforms?!? by Endive4Ever · · Score: 2, Insightful

      Two of the three projects using embedded devices that I wrote the code for used 4 bit processors. The third used an 8 bit processor. There are still many millions of 4 and 8-bit processors being designed into products. You can't even order a mask for said parts (the vendor won't even answer the phone, or often times even provide the emulator and tools) if you're not talking 500K+ quantities.

      --
      ---
    5. Re:Embedded platforms?!? by Waffle+Iron · · Score: 2, Informative
      How many embedded devices are running 64-bit processors now?

      I believe that the 64-bit capable MIPS architecture found it's biggest success in the embedded processor market. From the wikipedia entry:

      In recent years most of technology used in the various MIPS generations has been offered as building-blocks for embedded processor designs. Both 32-bit and 64-bit basic cores are offered, known as the 4K and 5K respectively, and the design itself can be licenced as MIPS32 and MIPS64. These cores can be mixed with add-in units such as FPUs, SIMD systems, various input/output devices, etc.

      MIPS cores have been very successful, they form the basis of many newer Cisco routers, cable modems and ADSL modems, smartcards, laser printer engines, set-top boxes, handheld computers, and the Sony PlayStation 2.

    6. Re:Embedded platforms?!? by bobthemonkey13 · · Score: 4, Informative
      Actually, it can go either way:
      • More address space than physical RAM: Swap space, memory-mapped files, shared memory/IPC, or any other use of virtual memory that doesn't map onto physical memory. This is why 64-bit address space is good even for desktop machines that have less than 4GB of RAM.
      • More physical RAM than address space: Ten processes, each using a single 4GB memory space, can consume 40GB of physical RAM. This is how and why you can put more than 4GB of memory in an x86 machine -- the processor maps from (I believe) 36-bit physical addresses to the 32-bit addresses that processes see.
    7. Re:Embedded platforms?!? by epine · · Score: 4, Informative

      I hate to confirm your self diagnosis, but I have sad news to bear.

      If you wish to use memory mapped IO to your file system, which has some good technical properties, you need a pointer with an address range *at least* as large as the largest possible file you might need to access, and preferably as large as the largest file system you intend to mount.

      Addressibility and physical storage are somewhat orthogonal. (In theory, there is no difference between theory and practice, in practice there is.)

      On a machine with 10G of memory, there is no reason for a process to use 64-bit pointers if the process doesn't require more than 32 bits of addressibility. If you look at Apache in the standard threading model, every request is managed by a different process. I doubt you need 64-bit pointers for *each* PHP instance, regardless of how much physical memory the machine contains.

      On the other hand, you might be doing some kind of video stream manipulation on a 10GB file using a machine with only 1GB of physical RAM. You would require the use of 64-bit addressibility for this task if you choose the memory mapped IO model.

      So yes, you are retarded, but it could be cured by thinking before you type (the post does mention memory mapped IO). There: ten simple words of advice that should apply to 2^33 members of the slashdot community.

    8. Re:Embedded platforms?!? by cant_get_a_good_nick · · Score: 2, Interesting

      The HURD code to access disks uses mmap() calls, so is currently limited on 32 bit architecture to 2GB disks. Every partition has to be less than 2GB, which is a pain in the ass for todays >100GB drives.

  4. Don't use 64-bit pointers on such systems. by Green+Light · · Score: 5, Insightful
    However, 64-bit pointers take up twice as much memory, which immediately affects memory footprint. This is especially an issue on embedded platforms where RAM is at a premium

    Huh? On systems where RAM is at a premium, I don't see the point of using or having 64-bit pointers.
    --
    "Send an Instant Karma to me" - Yes
    1. Re:Don't use 64-bit pointers on such systems. by Pseudonym · · Score: 4, Informative

      The poster named one point: mapping large files.

      Using mmap() for certain kinds of I/O is very, very useful in performance-sensitive applications. Using POSIX I/O (i.e. read(), write() and its relatives) means that your data must go through memory twice: once from disk into the buffer/page cache and then once again into userland. Memory-mapped I/O effectively unifies the two, saving on precious memory and memory bandwidth.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  5. Trade-offs by El · · Score: 3, Interesting

    There is always potential trade-offs between run speed and memory space. For example, you could always use a single 64-bit pointer, and save all your addresses as 32-bit or even 16-bit offsets from that pointer (requiring pointer arithmetic to access any object). Then you would use less memory, but your code would run faster.

    --

    "Freedom means freedom for everybody" -- Dick Cheney

  6. Latency by andrewl6097 · · Score: 2, Interesting

    Given that memory access times are bound by latency far more than bandwidth, the effect of loading another four bytes into the register file is most likely insignificantly small. I'm certain that 8-byte register-to-register operations *are* insignificantly small, and it's likely that pointers, given that they are not large but often accessed would be kept in registers. It would depend highly on the particular architecture.

    1. Re:Latency by Zetta+Matrix · · Score: 3, Insightful

      Parent has interesting point, but it doesn't address the cache issue. 64-bit pointers will take twice as much space as 32-bit pointers. In a jump table situation, for instance, a 128-byte cache line (picking a reasonable number) could only hold 16 pointers instead of 32. Of course, as was also mentioned, when you have hardware that is designed to address more than 4 GB of memory, the amount of cache and main memory available is usually scaled up accordingly to deal with it. Bigger processor, bigger cache, more RAM, Moore's Law marches on.

      So, basically, don't worry about it... it's the price of progress. Unless you're running a 64-bit platform on a pitifully small amount of RAM.

  7. 64 bit embedded processors? by Suppafly · · Score: 2, Insightful

    Does anyone use 64 bit processors for embedded applications?

  8. Implications of 64 bit pointers for interpreters by swdunlop · · Score: 4, Insightful

    There's an interesting discussion of 64-bit immediate values at the following link: 64 bit immediates in Python

    If we are already using 64 bits for our pointers, a virtual machine has the potential of exploiting a the pointer's larger footprint for other immediate values. I'm not as crazy about using the MSB of the pointer for indicating an immediate as Ian Bicking appears to be, I'd recommend using the LSB since it's easier to bias any object to an even address than halve the potential addressable space.

    Then again, if the potential address space is 2 ** 64, I suppose it's not such a sacrifice.

  9. Re:Who cares? by Smidge204 · · Score: 3, Insightful

    The truth of the matter is that your everyday user just has no need to handle numbers of that size or data of those quantities.

    Now where have we heard that before...
    =Smidge=

  10. Probably not as big a deal as you think. by Anonymous Coward · · Score: 5, Interesting

    With modern processors it's not uncommon to require 64-bit or 128-bit memory alignment on data structures to get the best performance. There are even some instructions that *require* such data alignments in order for them to work at all (for example: MMX or SIMD).

    Because of these existing data alignment issues, going from 32-bit to 64-bit pointers may have absolutely no impact on a program's memory usage and cache performance. It is highly likely you're already using 64-bit alignment when you enable the compiler's optmizations.

    Unless you're building massive linked lists of stuff in a scientific / simulation environment this is probably something not worth worrying about. The efficiency and volume of your actual data will still be the biggest waste of space - and it's not like you won't be able to attach more physical memory onto your new system than the old one.

    If it does effect you... you probably already know what you're doing or you've been making very bad assumptions about the size of your variable types.

    1. Re:Probably not as big a deal as you think. by ratboy666 · · Score: 2, Informative

      Of course a 64 bit pointer is 2x the size of a 32 bit pointer... 32 bit pointers only need 4 byte alignment, and thus pack nicely. So 64 bit pointers will take twice the cache space.

      And... the pointers have to be loaded. It will take more address bits in the instructions to build constants. More cache used.

      It is NOT highly likely that 64-bit alignment is done when optimizing. In fact, that's just wrong.

      Yes, cache performance suffers.

      --
      Just another "Cubible(sic) Joe" 2 17 3061
    2. Re:Probably not as big a deal as you think. by MarkCollette · · Score: 3, Interesting

      Since no one who responded to you believes you, I thought I'd add in.

      Yes, x86 does not require alignment for the vast majority of data accesses, with pretty much the sole exceptions being SIMD instructions. And yes, that will run psychotically slower than aligning the data, which is why the compiler does it. Look into your MS VC++ optimization setting and see if it's using 4 byte or 8 byte alignment of structures by default. My goodness, it's 8 byte alignment, but why you ask? Because doubles need 8 byte alignment or else performance drops off a cliff. So don't discount alignment.

      As well, most code uses relative addressing with instructions, not absolute addressing, so don't expect all memory references to suddenly double, especially with stack caching of variables (which would be relative from the stack pointer).

      And finally, if 64 bitness makes caches be half full of zeros, look forward to chip manufacturers to include compression circuitry to alleviate that problem.

      - Mark Collette

  11. First you gush about having over 4 GB of RAM by HotNeedleOfInquiry · · Score: 2, Insightful

    Then you whine about using an extra 4 bytes per pointer to address it. Seems to me that the number of pointers relative to the amount of RAM is so small it's not an issue. Correct me if I'm wrong.

    --
    "Eve of Destruction", it's not just for old hippies anymore...
  12. sparc64 by keesh · · Score: 3, Informative

    With linux on sparc64, typical applications are 30% slower when running in 64bit userland mode as opposed to 32bit userland mode. There are of course exceptions...

    1. Re:sparc64 by Frequanaut · · Score: 3, Insightful

      wha??? Any linkage to back this up?

  13. Re:Who cares? by peter · · Score: 5, Informative

    It's not that 32bit processors are a problem, it's that their virtual address space is not very big. 64bit processors can mmap anything you want, even block devices >> a few terabytes. (So if the HURD ever gets ported to AMD64, they can support filesystems > 2GiB, which they don't last I checked because they mmap the device, and the HURD only runs on i386!)

    Being able to mmap anything you want is something you just plain can't do on a 32bit CPU. If you want to write programs that don't worry about address space limitations, you need 64bit. Anything that simplifies programming is good, since programmer time is valuable.

    Besides that, even if you have 1GB of RAM on i386, Linux needs highmem support to use it all. (It reserves 3GB of virtual address space for user space, and the kernel maps as much RAM as it can with the address space that's left over after mapping PCI and AGP space. So 64bit is useful even on good desktop machines right now. (using highmem slows the kernel down, so might not even be worth it to map the last ~100MiB if you have 1GiB installed.)

    Stupid crap like highmem is exactly why we should be using 64bit CPUs.

    --
    #define X(x,y) x##y
    Peter Cordes ; e-mail: X(peter@cordes , .ca)
  14. IA64 programming by Twister002 · · Score: 4, Informative

    Raymond Chens web log. Lately he's been discussing IA 64 programming. I don't pretend to understand 1/2 of what he's talking about but I thought some of the readers here might be interested in what he has to say.

    --
    "For a successful technology, honesty must take precedence over public relations for nature cannot be fooled." -Feynman
  15. 2 comments by wayne606 · · Score: 2, Interesting

    First of all there is no such thing as a typical program... If you are writing a lisp interpreter where everything is a pointer then you may see your memory usage almost double. If you have a numerical program that is dominated by huge arrays of floats you might not see any difference at all.

    Second, here is a trick I have seen - it seems a bit strange but works well if you encapsulate your data well. Keep in mind that objects are generally aligned to a 8-byte boundary (if they are malloc'ed). That means your low 3 bits are not used at all. If your objects have, say, 64 bytes of data in them (possibly after a bit of padding) then you are wasting 6 bits. Just store your pointers as 32-bit words, shifted over by 6 bits. When you want to dereference them, your get-the-pointer accessor function just shifts them back and gives you a 64-bit pointer.

    Now you have an effective address space of 256GB and your data size has not grown at all. Maybe you have taken a hit in performance but until you benchmark you never know...

  16. Video editing will become more widespread by tepples · · Score: 2, Insightful

    Now, this kind of stuff might be useful for...um...hard-core video editing...and really, really huge servers, but that's about it. The truth of the matter is that your everyday user just has no need to handle numbers of that size or data of those quantities.

    What happens when "your everyday user" wants to perform "hard-core video editing" on footage she shot of her family with her miniDV camcorder?

  17. Alpha by Tune · · Score: 2, Insightful


    I concur with your findings. Back in the days I was experiencing a little disconfort with the speed of my Pentium 90 running linux, I decided to buy a Digital Alpha system 266 MHz. Both systems were configured with 64 MB, and both ran Red Hat 5.2.

    Although the Alpha system is obviously superior in number crunching, I noticed it ran out of physical memory on a regular basis where my P90 whould still be happy. Part of the matter it that alpha binaries tended to be much larger, as was the kernel. But I'm also quite sure that a major part is primarily due to the increased amount of "lost" bits in pointers and memory alignments of small data structures.

    --
    The problem with engineers is that they tend to cheat in order to get results. The problem with mathematicians is that they tend to work on toy problems in order to get results. The problem with program verifiers is that they tend to cheat at toy problems in order to get results.

  18. And segments...? by StarBar · · Score: 2, Informative

    On CPU:s with segments the impact must be much less if even at all. Say for instance that you reside in a 32 bit segment X and 16 bit subsegment Y then you would use 16 bit storage of pointers in RAM even though the CPU constructs the full 64 bit pointer internally by concatenating all the parts from the segment registers with the 16 bit from RAM.

    I don't assume any CPU in particular just the principle of segments.

  19. Answer: yes by p3d0 · · Score: 2, Interesting
    A while back, I was looking into more efficient heap storage of Java objects, and found that the heap of a variety of Java programs consist of about half pointers and half ints. The next most common type was booleans, and they were under 1%. Everything else was vanishingly small.

    Thus, you can expect Java heaps to expand by about 50% when moving from 32-bit to 64-bit pointers. What effect this has on your program's performance depends on the relation between the program's resident sets and the machine's cache. For instance, if your program has a resident set of 200KB on a machine with a 256KB cache, then the extra 50% will blow the cache and kill your performance. If the resident set were 150KB, the performance impact would probably be minimal.

    Disclaimer: I was doing this as a pet project in my spare time, so take these numbers with a grain of salt.

    --
    Patrick Doyle
    I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
  20. 64 bit pointers on embedded platforms? by polyp2000 · · Score: 2, Interesting

    >This is especially an issue on embedded platforms where RAM is at a premium... What kinds of embedded platforms are likely to be needing greater than 4gb RAM anyhow? I sure as hell cant imagine a use for a 64bit washing machine with upwards of 4gigs .. Thats a hell of a lot of washing programmes.

    --
    Electronic Music Made Using Linux http://soundcloud.com/polyp
  21. Minor increase in memory use by isj · · Score: 2, Informative

    A few years back I did a test with a server which store state information (I will not bore you with the details). I did some performance test on both the 32-bit version and the 64-bit version. Same source code. Same test data. Same configuration. On HP-UX 11.0 PA-RISC with the aCC compiler.
    The 64-bit version used about 15% more memory than the 32-bit version. But it was also 20% percent faster. That still puzzles me, because the server does not perform any 64-bit operations.

  22. Why not use 16 bit code, then? by gillbates · · Score: 4, Informative

    Seriously, it is faster. I've been writing in assembly for years, and unless I need a 32 bit pointer, I generally don't use them.

    If you're that concerned about performance that you are analysing pointer size, you might as well code in assembly. Yes, 64 bit pointers have a bigger footprint, but we experienced the same problem when we went to unicode strings, 32 bit code, etc...

    My advice is this: let the compiler deal with it. Unless you are willing to crank out a lot of hand-coded assembly or are interfacing with hardware, the 32/64 bit pointer question is pretty much moot. As it is, you can't control:

    • Where your linker places segments in the loaded image. Trust me, this is a big source of cache misses on the older processors where the libraries were in one area of memory and the running code in another.
    • The optimal ordering of instructions to keep the U and V pipelines of the processor filled. Some of the modern compilers can do this pretty well, but you can never be too sure. The number of clock cycles an instruction takes can vary by a factor of 3, so unless you're willing to learn some pretty hardcore assembly, you're stuck with whatever the compiler gives you.
    • The instruction level optimization of the compiler. Intel's new C++ compiler will turn the familiar array initialization code:

      for (int x = 0; x < 256; x++)buffer[x] = 0;

      Into something like this:

      mov cx,64
      mov eax,0
      mov si,buffer
      cld
      rep stosd


      Instead of the literal translations of the old compilers:

      mov si,buffer
      mov bx,0 ; this is the x variable
      forlabel@10001:
      mov [bx + si],0
      mov ax,1
      add ax,bx
      xchg bx,ax
      cmp bx,256
      jl forlabel@10001


      The former takes 68 instruction cycles, the later takes (6 * 256 + 2) = 1576!

    The aforementioned issues have a much bigger impact on performance than pointer size. Given that the memory bus is at least 64 bits wide on anything newer than a pentium, you won't incur a clock cycle penalty for using 64 bit pointers.

    The only thing that I would suggest is to watch where you place pointers in structures. For example, when building a linked list, you would want to do something like this:
    class link {
    link * ptrforward;
    link * ptrbackward;
    link * ptrdata;
    }
    rather than:
    class link{
    link * ptrdata;
    link * ptrbackward;
    link * ptrforward;
    }
    Because the processor pulls 64 bits per address accessed, the former structure would have the forward pointer in cache regardless of the pointer size. With the second structure, traversing a list in the forward direction would result in a cache miss on every node visited, regardless of pointer size (This applies only to the x86...).

    My experience has been that pointer size is only relevant on truly tiny systems - for example, 16 bit code which has to fit into a few kilobytes. Usually, as programs scale to work with larger datasets, the percentage of memory used for pointers decreases rapidly. You'll find that as data sizes increase, the practical uses for linked structures shrink; locating an element by using a binary search on a sorted array scales much better than a linear search traversing linked list.

    --
    The society for a thought-free internet welcomes you.
  23. Re:Quick Quiz by tbakker · · Score: 2, Informative

    Cyber 180