Sunday, April 27, 2008

32 bit or 64 bit

Theoretically a 32 bit processor can address 2^32 bits or 4 GB of memory, where as a 64 bit processor can address 2^64 bits or 16 exabytes of memory. The speed of computing should not differ much. But the fact that a 64 bit processor has 64 bit wide address space, it can perform large calculations faster as compared to 32 bit processors.

Generally, you would not even realize whether you have a 64 bit system or not. I did not realize that my cpu was 64 bit untill last week (after 6 months of having the system). Even if you have a 64 bit cpu, you might have loaded a 32 bit OS on it.

if you do a "uname -a", it would spill out the details of the kernel.
For a 32 bit system it might be something like
Linux jayantbox 2.6.24-16-generic #1 SMP Thu Apr 10 12:47:45 UTC 2008 i386 GNU/Linux
And for a 64 bit system, it would be something like
Linux jayantbox 2.6.24-16-generic #1 SMP Thu Apr 10 12:47:45 UTC 2008 x86_64 GNU/Linux

Then, how do you identify if your cpu is 32 bit or 64 bit? If you know your cpu model no, you can google for it and you might find out that theoretically your cpu is a 64 bit or not. Another way is to do a

jayant@jayantbox:~$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm ida
bogomips : 3994.26
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

The lm flag tells that the cpu in 64 bit wide.

So, you would say, if there is no increase in computing power, what benefit would i get out of using a 64 bit machine?

Well, firstly, if you need your applications to address more than 4 GB of memory, you definitely need a 64 bit system. So suppose you have a machine with 16 GB RAM and you need to run java with a heap size of 10 GB, or run mysql on it with a key_buffer of 8 GB then the only way you can do it is by using 64 bit OS on a 64 bit cpu. With 32 bit system, java can have a max heap size of only 2-2.5 GB and mysql can have a key_buffer size of only 4 GB.

But, desktops. They dont have such large amounts of RAM. Then a desktop should not be a 64 bit system.

Well, untill now, my experience says that if you are using your desktop for general purposes like word processor, games, net browsing etc, then it does not make sense to use a 64 bit system. Cause i found it difficult to get 64 bit stable binaries for most of the programs that i used to use. But if you are using it for heavy processing, development, then 64 bit might help. After shifting to a 64 bit machine, i found out that my system load has gone down a bit and that performance has improved a little (not a huge difference). There is ofcourse a geeky index linked with the use of a 64 bit system.

But 64 bit systems, as of today are meant for servers and not for desktops.

a 64 bit machine can perform large calculations in hardware faster by using 64 bit integers instead of emulating 64 bit operations using a bunch of 32 bit integers. So, you might find heavy games running better on 64 bit platform as compared to a 32 bit platform. But 64 bit platform requires more cache space for the same program on a 32 bit platform due to the bloated pointers and argument padding used in 64 bit systems. You might also come across some 64 bit programs which are slower than 32 bit programs. My personal thought on this is that those programs are not yet optimized to run on 64 bit platforms.

Lets list the pros and cons of using a 64 bit platform as compared to a 32 bit platform.

1. 64 bit platform has large address space as compared to a 32 bit platform.
2. Big calculations at hardware level at hardware level are faster in 64 bit platform as compared to 32 bit platform
3. The same program occupies more memory due to bloated pointers and argument paddings.
4. Binaries compiled on 64 bit platforms are larger as compared to binaries on 32 bit platform.
5. Most commercial softwares are built for 32 bit platform. So finding pre compiled softwares for 64 bit platform might be difficult.

There are cases when you would want to run a 32 bit binary on 64 bit platform - for which 32 bit emulators are available.

You can have a look at some benchmarks for UltraSPARC platform using Solaris 9 here:

1 comment:

whytook said...

Thanks that was really helpful and appreciated.

Problem I find is when you have several servers and you try to find out the basic 'what I've got' info like "is it 32-bit or 64-bit?" that varies per MFG (IBM, HP, SOL). (Ah business). Here's a great site to check commands across platforms (you may already have something similar)

Thanks again!