5 ms·
When the discussion was ongoing about what the 'native' length for an int should be in Java the group did some profiling on machines to compare 32 bit, 64 bit o
by ChuckMcM 11y ago
When the discussion was ongoing about what the 'native' length for an int should be in Java the group did some profiling on machines to compare 32 bit, 64 bit on 32 bit, and 64 bit native, and 32 bit on 64 bit performance. Generally 32 bit on native or 64 bit platforms was pretty much the same. Emulated 64 bit (where the compiler had to generate extra code to do the math operations) was about .1% slower. (yes one tenth of one percent). In investigating it the dominant factor in program execution was not instructions per second but fetch time from DRAM into the cache. All of the math operations fit in the cache and so executed at full clock rate. As the typical CPU at the time was 1Ghz with an execution efficency of 1.2 to 1.5 IPC, during the 110ns where the CPU was waiting for the next bit of data from the RAM to get into the cache it could execute 60-80 instructions. So generally the "extra" instructions were essentially free for the most part. So Java got 64 bit integers regardless of the underlying processor architecture.
Footnote: I have mis-remembered the system performance numbers, the SS10 was a 50Mhz machine. The R4000 (native 64 bit machine was only 100Mhz. That said, the CPU being 'starved' while it waited for the cache to fill was the proximate analysis of why the performance differed very little.
- boomzilla 11y agoJava has both int (32 bit) and long (64 bit) types. What did you refer to as 'native'? Lucene, the popular core search library, has always used int as internal document IDs. As a result, the number of documents in one Lucene index is limited to 2 billions (Java int are signed). It's even worse if there are many deleted docs in the index as they are are just marked as deleted and consume up IDs. There are a number of reasons why no one is keen on moving internal docIDs to long, and performance is one of them.
- ChuckMcM 11y agoWow, and thanks for that. You are absolutely correct that Java exported all of the various integer sizes. Odd that I can clearly remember the debate and mis-remember the final outcome. Bill Joy was pretty adamant about "fixing" the various sizes of integers problem that C had been going through on x86 with the whole sizeof(int) != sizeof(ptr) code and we benchmarked it and it did not affect performance hardly at all. Wow it sucks getting old.
- userbinator 11y agofetch time from DRAM into the cache I suspect Java code on average does far more pointer-chasing and function calls than pure maths, so the difference wouldn't be very visible.