Closed Bug 1610820 Opened 5 years ago Closed 1 month ago

CheerpJ generated code runs up to 10x slower on Firefox compared to Chrome

Categories

(Core :: JavaScript Engine, defect, P3)

74 Branch
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: linuxhippy, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(1 file)

Attached file JavaFiddle.java

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0

Steps to reproduce:

CheerpJ is a Java -> JavaScript compiler, much like EmScripten but for Java instead of C++.

  1. Pasted the Java-Benchmark attached into CheerpJ's Fiddle tool
  2. Clicked the "run"-Button

Actual results:

Firefox takes about 10x as long to complete a benchmark run compared to Chrome.

Native Java: 40ms
Chrome: 310ms
Firefox: 3200ms

Expected results:

Firefox should be somewhere in the same ballpark as Chrome, not 10x slower.

Hi, Clemens!

Thanks for your contribution!

I don´t have the technical knowledge in order to reproduce this but I'm adding product and component to this issue to keep on track.

Please let us know if this issue is reproduced in the latest Nightly edition. You can download it from here: https://nightly.mozilla.org/

If you still have the issue please create a new profile, you have the steps here: https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles?redirectlocale=en-US&redirectslug=Managing-profiles#w_starting-the-profile-manager
support.mozilla.orgsupport.mozilla.org

Once you have all this information, please let us know so we can continue investigating.

Regards,

Component: Untriaged → JavaScript Engine
Product: Firefox → Core

So, on my machine the results are worse in the sense that I get a slow script dialog in nightly.

The fiddle website is here: https://javafiddle.leaningtech.com/

A profile is here: https://perfht.ml/2RChKU0

I suspect this benchmark is stressing the GC, as I see in the profile we're effectively constantly doing a GCMinor with reason OUT_OF_NURSERY.

Matthew:
I just had a look at how the generated code behaves with chrome and there I can't see excessive heap allocations.
Maybe the reason for firefox being so slow running this test is the compiler is not able to elliminate some of the allocations?
The java-code itself should be allocation-free except for the start of each benchmark round.

Priority: -- → P3

Matthew:
Looks like this code does next thing in the loop:

var rewrittenFunc = new Function('a', 'b', "_"+caller.name, rewrittenCaller);

I don't know how Chrome can optimize it.

Severity: normal → S3

Is this fixed for you?

Flags: needinfo?(linuxhippy)

I suspect that expanding the eval cache to also cover new Function would help a lot here.

Depends on: 1420440
Blocks: sm-js-perf
Type: enhancement → defect

A needinfo is requested from the reporter, however, the reporter is inactive on Bugzilla. Given that the bug is still UNCONFIRMED, closing the bug as incomplete.

For more information, please visit BugBot documentation.

Status: UNCONFIRMED → RESOLVED
Closed: 1 month ago
Flags: needinfo?(linuxhippy)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: