Closed Bug 785761 Opened 8 years ago Closed 7 years ago

IonMonkey: speed up cancelling off thread compilations

Categories

(Core :: JavaScript Engine, defect)

Other Branch
x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: bhackett1024, Assigned: bhackett1024)

References

Details

(Whiteboard: [ion:t])

Attachments

(1 file)

Currently, when an off thread compilation needs to be cancelled, due to a GC or new type info, the main thread sits idle until the compilation fully finishes and its results thrown away.  On my computer, this leads to about 4 ms of main thread idle time on SS, which will increase if we start compiling more eagerly.  It would be better if the main thread could asynchronously stop the compilation, with a different but similar-functioning mechanism to JSRuntime interrupts.
Attached patch patchSplinter Review
Add an interrupt mechanism to MIRGenerator, trigger it when canceling builds on the main thread, and regularly poll it in most analysis phases in Ion.  Polling in the main loop of analysis phases turned out better than only polling between phases, as some phases take up to 1ms or more even on SS-sized scripts.  This cuts the amount of time spent canceling compiles on SS to <.5ms for me, and with bug 785494 the improvement over a run without off thread compilation is about 8ms.
Assignee: general → bhackett1024
Attachment #655567 - Flags: review?(dvander)
Comment on attachment 655567 [details] [diff] [review]
patch

Review of attachment 655567 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/ion/MIRGenerator.h
@@ +64,5 @@
>          return compartment->rt->spsProfiler.enabled();
>      }
>  
> +    // Whether the main thread is trying to cancel this build.
> +    bool shouldCancel(const char *why) { return cancelBuild_; }

nit: expand these to be
    bool shouldCancel(const char *why) {
        return cancelBuild_;
    }

etc
Attachment #655567 - Flags: review?(dvander) → review+
Backed out by https://hg.mozilla.org/integration/mozilla-inbound/rev/54591f4e0f79 due to failure to build on Android, see https://tbpl.mozilla.org/php/getParsedLog.php?id=16464605&tree=Mozilla-Inbound:

../../../js/src/ion/Ion.cpp: In function 'js::ion::LIRGraph* js::ion::CompileBackEnd(js::ion::MIRGenerator*)':
../../../js/src/ion/Ion.cpp:769: error: converting 'false' to pointer type
../../../js/src/ion/Ion.cpp:777: error: converting 'false' to pointer type
../../../js/src/ion/Ion.cpp:785: error: converting 'false' to pointer type
(and many more similar errors).
Per Try, this one seems to keep the Android compiler happy.

https://hg.mozilla.org/integration/mozilla-inbound/rev/8a6b6b5f3e55
https://hg.mozilla.org/mozilla-central/rev/8a6b6b5f3e55
Status: NEW → RESOLVED
Closed: 7 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.