News for hackers. Stuff that matters.
Re:64-bit Firefox for Windows should be prioritized, not sus... by kevingadd on Tuesday November 27, 2012 @05:12AM (#4836485)
64-bit Firefox is slower for some workloads because the JavaScript heap is dramatically larger (Due to the doubled pointer size). As it happens, large portions of Firefox are written in JavaScript...

I'm sure there are some use cases where it's faster, of course, but having your heap be 50-100% larger (yes, really that much, I've measured it) is pretty hard to overcome just by adding a few extra registers.

I expect this is why Java has support for using 32-bit object pointers in 64-bit mode. Features like that would probably help Firefox tremendously.

Re:64-bit Firefox for Windows should be prioritized, not sus... by stephencanon on Tuesday November 27, 2012 @06:59AM (#4836757)
Heap growth moving from 32b to 64b is rarely on the order of 50-100% larger. 20-30% is much more common (100% would imply that your application stores no actual data, only pointers and sizes; I know that pointer-chasing is very much in style these days, but that's ridiculous. Even the 1:1 ratio implied by a 50% figure is an extreme outlier).

Further, raw heap size typically has marginal impact on performance; locality of reference and size of working set are far more important. It doesn't matter if your raw heap usage grows by 30% if the majority of your accesses are to the same working set of data either way.

At the same time, a well-crafted interpreter or JIT (which people seem to think is important in browsers) benefits heavily from increasing the size of the register set. Even in more typical use cases, even without aggressive optimization, speedups of 10-20% are common in moving from x86 to x86_64.

Re:64-bit Firefox for Windows should be prioritized, not sus... by kevingadd on Tuesday November 27, 2012 @08:14AM (#4836965)
You can tell me what your think the behavior is actually like, but I can point you to a HTML5 game that uses 50-100% more JS heap and runs slower in 64-bit builds of Firefox :)

You say a larger heap has marginal impact on performance and that locality and working set size are what matter. If larger pointers make the heap bigger, then the working set is going to grow as well, and locality will be worse because the larger pointers mean less objects fit into a cache line.

Re:64-bit Firefox for Windows should be prioritized, not sus... by stephencanon on Tuesday November 27, 2012 @08:21AM (#4836987)
I'm not saying 50-100% growth doesn't happen, I'm saying that it's an outlier (based on complete system data from multiple platforms).

If it's really a common issue with firefox's JS implementation for some reason, there's nothing to stop them from using a compressed pointer scheme for JS that uses 32b pointers and a known offset; it's a common technique. You give up one register to keep the offset around, but you've still netted 7 registers from the switch to the 64b ISA, and adding the offset is either a simple OR or can be folded into an LEA (nearly free or free).

Let's not confuse "they haven't had a chance to tune the 64b JS engine, and the 32b one has been worked on for years" with "x86_64 is slower than x86_32".

Re:64-bit Firefox for Windows should be prioritized, not sus... by nuje on Tuesday November 27, 2012 @08:48AM (#4837065)
Is your "complete system data from multiple platforms" from JS apps?

Let's also not confuse "a sufficiently smart compiler..." with real-world observed performance :)

BTW data layout transformations like compressed fields would also be useful on 32-bit. The vast majority of object graphs would be happy with 16 or even 8-bit identifiers, not to mention JS numbers which are all 64-bit floats even on 32-bit platforms.

Re:64-bit Firefox for Windows should be prioritized, not sus... by Dylan16807 on Tuesday November 27, 2012 @01:50PM (#4838140)
Let's also not confuse differences caused by 32 bit engines having more developers with differences caused by the platform.
Re:64-bit Firefox for Windows should be prioritized, not sus... by brigade on Tuesday November 27, 2012 @10:52AM (#4837439)
Please don't assert logical fallacies as the truth.

"x86-64 is slower because pointers are larger" does not follow from "Firefox's JavaScript engine is slower and uses more memory on x86-64"

Re:64-bit Firefox for Windows should be prioritized, not sus... by kevingadd on Tuesday November 27, 2012 @10:57AM (#4837466)
I never said anything of the sort. Maybe read my posts before replying to them?
Re:64-bit Firefox for Windows should be prioritized, not sus... by Symmetry on Tuesday November 27, 2012 @09:16AM (#4837179)
It might be that it's simply Firefox's JavaScript interpreter which hasn't been optimized for 64-bits. As far as I know other JavaScript interpreters don't suffer from this problem, and with LuaJIT, which should be fairly similar to a JavaScript JIT compiler, at least I have the numbers to back it up: http://luajit.org/performance_x86.html
Re:64-bit Firefox for Windows should be prioritized, not sus... by nuje on Tuesday November 27, 2012 @09:23AM (#4837207)
Those LuaJIT numbers are really microbenchmarks with small working sets though, and wouldn't show the cache effects of increased memory usage.
Re:64-bit Firefox for Windows should be prioritized, not sus... by Dylan16807 on Tuesday November 27, 2012 @01:59PM (#4838198)
LuaJIT doesn't have increased memory usage. 32 or 64 bit, it always packs pointers into the low bits of NaN doubles. Addresses fit because current 64 bit chips actually use 48 bit addresses.

(LuaJIT also uses a limited memory arena for allocations but it's not inherent to the design; it could be changed but the current garbage collector can't handle that much data)