News for hackers. Stuff that matters.
Re:Firefox’s new streaming and tiering compiler by markdog12 on Wednesday January 17, 2018 @12:08PM (#16169619)
https://lukewagner.github.io/test-tanks-compile-time/

Firefox Nightly: WebAssembly.instantiate took 227.6ms (54.4mb/s)

Chrome Canary: WebAssembly.instantiate took 8576ms (1.4mb/s)

Wow.

(Edit: And I believe that's not even using the streaming compilation mentioned in the article, it's just the new baseline compiler in action)

Re:Firefox’s new streaming and tiering compiler by callahad on Wednesday January 17, 2018 @12:31PM (#16169842)
> I believe that's not even using the streaming compilation mentioned in the article

That's correct. Streaming compilation would finish earlier, but might actually benchmark more slowly because you'd be adding in the time that the compiler is idle and waiting for the network to catch up.

Preloading the .wasm file in the test lets us measure just the speed of the compiler, independent of the network.

Re:Firefox’s new streaming and tiering compiler by derefr on Wednesday January 17, 2018 @12:53PM (#16170075)
An interesting benchmark would be the total energy usage of the CPU while loading a page in each browser. The compiler managing to idle waiting for network packets should theoretically allow some of the CPU cores to enter sleep states. (Not all, since others are still busy rendering the page, and at least one is busy doing whatever non-DMA kernel bits are involved with receiving the network packets.)
Re:Firefox’s new streaming and tiering compiler by etep on Wednesday January 17, 2018 @04:21PM (#16171943)
It should be the case that if the same amount of work is done, then the energy used will be the same. If it takes less work to compile the web assembly, then less energy (holding all other parameters the same). If you have to idle a CPU, then you probably use more energy (holding all other parameters the same) i.e. because you will spend more time and accomplish the same amount of real work (but waste energy on the idled core, albeit waste very little, accomplishing extra, but non-productive, work). Cannot let some other CPU parameter changes as a result of cores being idled (e.g. frequency gets boosted on non-idle cores as a result of dynamic frequency scaling with idle cores) to run this experiment. Thinking about CPU energy use is interesting :)
Re:Firefox’s new streaming and tiering compiler by yjftsjthsd-h on Wednesday January 17, 2018 @05:15PM (#16172539)
I don't think that's true; isn't the relationship between clock speed and power non-linear?
Re:Firefox’s new streaming and tiering compiler by chongli on Wednesday January 17, 2018 @11:11PM (#16174635)
The real killer with energy usage in browsers is idle wake ups per second. If you've got a lot of tabs open and they're all running timers, waking up, hitting the network, etc. then they're keeping the CPU from going into low power state and thus wasting a lot of energy.

Even though I'd prefer to use Firefox I tend to stick with Safari due to the battery life advantage which really shows when you open a lot of tabs.

Re:Firefox’s new streaming and tiering compiler by lloeki on Thursday January 18, 2018 @04:16AM (#16175752)
Indeed the most dramatic improvement I saw in battery life was when macOS and Safari started cooperating around timer coalescing using App Nap.
Re:Firefox’s new streaming and tiering compiler by ethbro on Wednesday January 17, 2018 @05:57PM (#16172886)
That's for max frequency on a given process node. Power scales with voltage squared. But that doesn't say anything about wasted power. And dynamic scaling screws that up in modern chips.

I believe I could summarize things by saying the only way you can really save energy* doing the same work+ is by using a different semiconductor process (either power/leakage-reduction-focused or smaller).

* For serious values of "energy"

+ Where the same work is not always true for a given task, if one optimizes an algorithm

Re:Firefox’s new streaming and tiering compiler by naikrovek on Wednesday January 17, 2018 @09:57PM (#16174288)
Can you explain the voltage squared thing? To me, power = voltage * current.
Re:Firefox’s new streaming and tiering compiler by mmwelt on Thursday January 18, 2018 @12:47AM (#16174986)
Even for purely resistive loads, power is proportional to the square of the voltage:

  P = V * I
But,

  I = V / R
So,

  P = V * (V / R)
    = V^2 / R
Re:Firefox’s new streaming and tiering compiler by etep on Wednesday January 17, 2018 @10:20PM (#16174397)
For chips, power scales with voltage squared. Is also true that P=IV (since both are true, these observations cannot be in contradiction). Apparently, for chips, the current must be proportional to voltage also. Glossing over some details, turning on (off) a transistor is the same as charging (discharging) a capacitor. The energy stored on a capacitor is 1/2 C V^2. If you turn on and off the transistor periodically (say with frequency f) you use 1/2 C V^2 energy f times per second (energy per unit time is power). Normally the capacitance is ignored when discussing how power changes because for a given design the capacitance is a fixed quantity.
Re:Firefox’s new streaming and tiering compiler by Filligree on Thursday January 18, 2018 @08:34AM (#16176916)
Running a processor at higher frequency also requires increasing voltage, which increases effective capacitance by that same formula.

That's not the primary cause of the power = frequency^2 rule, but actually adds a factor on top of that.

Re:Firefox’s new streaming and tiering compiler by etep on Wednesday January 17, 2018 @09:38PM (#16174202)
I think it is linear for frequency and non-linear for voltage, i.e. P~fCV^2. But in many current CPUS, the feature that adjusts frequency also adjusts voltage. That's why I stipulated that, for my comments to be true, such shenanigans as dynamic frequency (and voltage) scaling must be "turned off." I think the OP was asking, what happens to CPU energy if you load the web page with and without the optimized compilation. The OP was interested in core sleep states, but I think that dynamic frequency scaling is a confounding factor. It would be interesting to see the measurements w/ and w/out that feature perhaps.
Re:Firefox’s new streaming and tiering compiler by tspiteri on Thursday January 18, 2018 @05:21AM (#16176001)
To increase the frequency, you also have to increase the voltage so that the transistors charge faster, otherwise they won't be able to switch in the shorter time.
Re:Firefox’s new streaming and tiering compiler by depressedpanda on Wednesday January 17, 2018 @01:24PM (#16170341)
I ran the tests on my Nexus 5X running stock Android 8.1.

Chrome: WebAssembly.instantiate took 12935.5 ms (1 MB/s)

Firefox Nightly: WebAssembly.instantiate took 1223.1 ms (10.1 MB/s)

Yikes, one order of magnitude in difference.

Re:Firefox’s new streaming and tiering compiler by alexeldeib on Wednesday January 17, 2018 @01:30PM (#16170405)
Similar for me, a touch over 10x

FF: WebAssembly.instantiate took 280.3 ms (44.2 MB/s)

Chrome: WebAssembly.instantiate took 3022.4 ms (4.1 MB/s)

Re:Firefox’s new streaming and tiering compiler by weaksauce on Wednesday January 17, 2018 @05:36PM (#16172716)
mine was even a bit more of a change.

Chrome: WebAssembly.instantiate took 13692.8 ms (0.9 MB/s)

Firefox: WebAssembly.instantiate took 330.8 ms (37.4 MB/s)

Re:Firefox’s new streaming and tiering compiler by flobbers on Thursday January 18, 2018 @08:50AM (#16176987)
Safari 11.0.2: 4.7mb/s Chrome: 1.2mb/s

This is on MacOS 10.13.2. I'd love to run Firefox but the battery savings and reduced heat from using Safari makes it too hard to pass up in this regard.

Re:Firefox’s new streaming and tiering compiler by schance on Wednesday January 17, 2018 @08:42PM (#16173921)
Chrome Dev: WebAssembly.instantiate took 2254 ms (5.5 MB/s)

Firefox Nightly: WebAssembly.instantiate took 158.2 ms (78.3 MB/s)

Edge 41.16299.15.0: WebAssembly.instantiate took 99.2 ms (124.8 MB/s)

I did not expect Edge to be even faster.

Re:Firefox’s new streaming and tiering compiler by markdog12 on Wednesday January 17, 2018 @09:01PM (#16174015)
As stated elsewhere in this thread, Edge compiles WebAssembly lazily, so it's basically skipping the test: https://news.ycombinator.com/item?id=16170496
Re:Firefox’s new streaming and tiering compiler by justinjlynn on Wednesday January 17, 2018 @08:52PM (#16173977)
Is the runtime performance similar to the startup performance measurement?
Re:Firefox’s new streaming and tiering compiler by mort96 on Wednesday January 17, 2018 @12:59PM (#16170127)
I'm running Firefox 57, and even here, Firefox is significantly faster; 3182.3ms (3.9mb/s) in Firefox, 7575ms (1.6mb/s) in Chrome 63.
Re:Firefox’s new streaming and tiering compiler by SubiculumCode on Wednesday January 17, 2018 @01:08PM (#16170201)
Chrome: WebAssembly.instantiate took 22861.1ms (0.5mb/s)

Nightly:WebAssembly.instantiate took 1825.3ms (6.8mb/s)

Mine was a laptop in low power mode. Yours was much faster all around.

Re:Firefox’s new streaming and tiering compiler by kbumsik on Wednesday January 17, 2018 @03:35PM (#16171542)
My old i5 Thinkpad L450:

Firefox 57: 5053.8 ms (2.4 MB/s)

Firefox Nightly 59: 454.6 ms (27.2 MB/s)

Chrome 63: 9034.9 ms (1.4 MB/s)

Wow, it's over x10 faster...

Re:Firefox’s new streaming and tiering compiler by therockhead on Wednesday January 17, 2018 @12:49PM (#16170048)
My times are similar. I also ran on Safari which is faster than Chrome but slower than Firefox.
Re:Firefox’s new streaming and tiering compiler by styfle on Wednesday January 17, 2018 @12:33PM (#16169870)
Where did you even find that repo? Was that mentioned in the article or is this your code?
Re:Firefox’s new streaming and tiering compiler by callahad on Wednesday January 17, 2018 @12:35PM (#16169888)
Linked in the article under "give it a try" in the sixth paragraph.

The repo itself is at https://github.com/lukewagner/test-tanks-compile-time

Re:Firefox’s new streaming and tiering compiler by clouddrover on Wednesday January 17, 2018 @07:51PM (#16173648)
In Firefox 58 beta I get: WebAssembly.instantiate took 200.9 ms (61.6 MB/s)

In Safari 11.0.2 I get: WebAssembly.instantiate took 2885.9 ms (4.3 MB/s)

In Vivaldi 1.13.1008.40 I get: WebAssembly.instantiate took 7719 ms (1.6 MB/s)

Re:Firefox’s new streaming and tiering compiler by vitorgrs on Thursday January 18, 2018 @01:17AM (#16175099)
I tried Chrome Canary, Firefox Nightly and Edge. Edge was the fastest here! But I believe they are using streaming compilation already.