New issue
Advanced search Search tips

Issue 720099 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

asm.js slow compared to Firefox 53.0.2 (64-bit)

Reported by dvd...@gmail.com, May 9 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3088.3 Safari/537.36

Steps to reproduce the problem:
1. Open https://plnkr.co/edit/hbjXulfBoGzx5PVR5SKH?p=preview (Or see attached files) in Chrome and Firefox
2. Click "Browse..." and select a big file so the hashing takes a few seconds.
3. Click "Hash File"

I get around 300MiB/s in Firefox while in Chrome I only get ~50MiB/s.
The asm part is clearly the bottleneck as the file reading part often waits for the asm part to be done.

What is the expected behavior?
Both browser to be almost equally fast

What went wrong?
Chrome is 6 times slower

Did this work before? N/A 

Chrome version: 60.0.3088.3  Channel: dev
OS Version: 10.0
Flash Version:
 
Filehashing.zip
5.7 KB Download

Comment 1 Deleted

Comment 2 by woxxom@gmail.com, May 10 2017

See https://bugs.chromium.org/p/v8/issues/detail?id=4203 - you need to enable chrome://flags/#enable-asm-webassembly

Comment 3 by ajha@chromium.org, May 10 2017

Labels: Needs-Triage-M60

Comment 4 by dvd...@gmail.com, May 10 2017

I've enabled the flag and tried again.
I got the same results as before ~50MiB/s.

I'm getting: 
Invalid asm.js: Invalid type after new. In ed2k.js:36
Probably because I'm not passing window for the stdlib parameter (ed2k.js:260).
I get the same error/warning in Firefox but I can't pass the window function since the asm code is started in a web worker.

Comment 5 by woxxom@gmail.com, May 10 2017

Well, only valid asm.js code is converted to wasm so there's probably nothing Chrome can do here. 

Comment 6 by woxxom@gmail.com, May 10 2017

On the other hand, this feature is a work-in-progress so it may be buggy.

Comment 7 by e...@chromium.org, May 10 2017

Components: -Blink Blink>JavaScript

Comment 8 by dvd...@gmail.com, May 10 2017

Sorry I accidentally deleted the plunker.
New one: https://plnkr.co/edit/nkqEeBMR3VIrZDLnAZ25?p=preview

I did some more testing:
If I pass self instead of null in ed2k.js:260 which is probably more correct and prefix the Uint32Array and Uint8Array types with stdlib in the asm code,
the console doesn't report "Invalid asm.js: Invalid type after new." anymore but "Invalid asm.js: Invalid number of arguments when creating heap view.", which is a few lines down from the previous error.
But instead of continuing (albeit slowly compared to FF) it stops executing there.
The constructor should exists going by http://html5index.org/Typed%20Arrays%20-%20Uint32Array.html

Comment 9 by dvd...@gmail.com, May 10 2017

Anyway there should be a way to write valid asm.js code in a web-worker while using the UintXXArray types.
Otherwise the two features can't be used in combination.
Owner: mstarzinger@chromium.org
Status: Assigned (was: Unconfirmed)
Cc: bmeu...@chromium.org jarin@chromium.org
Unfortunately it is not possible with asm.js to create heap views (i.e. with the UIntXXXArray) that don't start a offset zero and span the full size of the underlying array buffer. Only the single argument constructor is allowed. The is specified here (look for "A global heap view is of the following form"):

http://asmjs.org/spec/latest/#global-variable-type-annotations

Even if this would be fixed somehow, the code contains other JavaScript idioms that are just not part of asm.js which would cause subsequent validation failures. Taking a first glance I could spot the following:

- Parameter "state" and "data" are not primitive data types, both seem to be heap views.
- Missing type annotation for parameters (e.g. the "length" of "hashCore") and local variables.

In short, the provided code is not valid asm.js code (neither in Chrome nor in other browsers). That being said, I can see the performance difference described above. Might still be interesting for the JavaScript proper pipeline.

Sign in to add a comment