Closed Bug 1983154 Opened 1 year ago Closed 11 months ago

Prototype a JS Engine managed MicroTask Queue

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
145 Branch
Tracking Status
firefox145 --- fixed

People

(Reporter: mgaudet, Assigned: mgaudet)

References

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

Details

Attachments

(11 files, 2 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

A prototype of a JS engine managed microtask queue shows impressive performance improvement on doxbee-promise, a promise heavy microbenchmark from the JetStream 3.

This bug is to land a prototype disabled, to allow further evolution and evaluation before making it the default.

Flags: behind-pref+

Instead, get required information directly.

This is a more flexibile version

Patches just uploaded are WIP still, but worth sharing as the cover the general thrust of what we're looking at.

See Also: → 1983207
Assignee: nobody → mgaudet
Severity: -- → N/A
Priority: -- → P1
Attachment #9507213 - Attachment is obsolete: true
Attachment #9507214 - Attachment description: WIP: Bug 1983154 - Move ReactionRecord slots inside of class → Bug 1983154 - Move ReactionRecord slots inside of class r?arai
Attachment #9507215 - Attachment description: WIP: Bug 1983154 - Split CallSetup out of CallbackObjectBase → Bug 1983154 - Split CallSetup out of CallbackObjectBase r?smaug
Attachment #9507216 - Attachment description: WIP: Bug 1983154 - Add CallSetup that doesn't take a CallbackObjectBase → Bug 1983154 - Add CallSetup that doesn't take a CallbackObjectBase r?smaug
Attachment #9507217 - Attachment description: WIP: Bug 1983154 - Add javascript.options.use_js_microtask_queue → Bug 1983154 - Add javascript.options.use_js_microtask_queue r?arai
Attachment #9507218 - Attachment description: WIP: Bug 1983154 - Create MaybeGetPromiseAllocationSite → Bug 1983154 - Create MaybeGetPromiseAllocationSite r?arai
Attachment #9507219 - Attachment description: WIP: Bug 1983154 - Shell support for a JS MicroTaskQueue. → Bug 1983154 - Shell support for a JS MicroTaskQueue. r?arai
Attachment #9507220 - Attachment description: WIP: Bug 1983154 - Gecko Support for JS Micro Task Queue → Bug 1983154 - Gecko Support for JS Micro Task Queue r?arai!,smaug!

I don't love having a virtual dispatch on this hot path, but this is required for matching
existing semantics, as revealed by dom/workers/test/test_WorkerDebugger_promise.xhtml

Longer term I'd love to do something else.

Ok. Patches are up for review now. The goal right now is to land this disabled, and then once it's landed disabled we can collaboratively get the feature ready for shipping.

There's still a few known hangs from my most recent enabled run on try, but I don't think that needs to block review.

Blocks: 1987692
Attachment #9512104 - Attachment is obsolete: true

This refactoring splits the CallSetup constructor into some recyclable pieces.

Pushed by mgaudet@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d4d9ecdbaa7f https://hg.mozilla.org/integration/autoland/rev/2872b52ab1b7 Make Vector a parameter to ds/fifo.h r=jonco https://github.com/mozilla-firefox/firefox/commit/21cfaaa72b67 https://hg.mozilla.org/integration/autoland/rev/836c71f876d4 Support JS::Value in TraceableFifo r=jonco https://github.com/mozilla-firefox/firefox/commit/ffc3c5c997b3 https://hg.mozilla.org/integration/autoland/rev/3bea563d46d7 Move ReactionRecord slots inside of class r=arai https://github.com/mozilla-firefox/firefox/commit/899c61947f99 https://hg.mozilla.org/integration/autoland/rev/68776b8cfd6f Split CallSetup out of CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/6580fe91039e https://hg.mozilla.org/integration/autoland/rev/9463f3cca0bd Refactor CallSetup r=smaug https://github.com/mozilla-firefox/firefox/commit/13ae8ff28ab8 https://hg.mozilla.org/integration/autoland/rev/d3fd2071246c Add CallSetup that doesn't take a CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/14fa299fae54 https://hg.mozilla.org/integration/autoland/rev/3fd07495f952 Add javascript.options.use_js_microtask_queue r=arai https://github.com/mozilla-firefox/firefox/commit/175596aeb3e3 https://hg.mozilla.org/integration/autoland/rev/7db1dbd2babc Create MaybeGetPromiseAllocationSite r=arai https://github.com/mozilla-firefox/firefox/commit/4853489affc0 https://hg.mozilla.org/integration/autoland/rev/6d0b03a001bb Shell support for a JS MicroTaskQueue. r=arai https://github.com/mozilla-firefox/firefox/commit/0fa8e3467592 https://hg.mozilla.org/integration/autoland/rev/acc50d798db3 Gecko Support for JS Micro Task Queue r=arai,smaug,dom-worker-reviewers,asuth https://github.com/mozilla-firefox/firefox/commit/b97ab7b023f1 https://hg.mozilla.org/integration/autoland/rev/f7965dd529e0 Select debugger queue where required r=arai,smaug,dom-worker-reviewers,asuth
Pushed by imoraru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/80d03cf16647 https://hg.mozilla.org/integration/autoland/rev/a5c47db18247 Revert "Bug 1983154 Bug 1977466 - Select debugger queue where required r=arai,smaug,dom-worker-reviewers,asuth" for causing linux build bustages on Fifo.h.

Revert for causing linux build bustages on Fifo.h.

[task 2025-09-26T20:27:35.173+00:00] 20:27:35     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/js/src/intgemm'
[task 2025-09-26T20:27:35.175+00:00] 20:27:35     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -o IntegerGemmIntrinsic.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -ftrivial-auto-var-init=pattern -fstrict-flex-arrays=1 -DDEBUG=1 -DWASM_SUPPORTS_HUGE_MEMORY -DJS_CACHEIR_SPEW -DJS_STRUCTURED_SPEW -DJS_HAS_CTYPES -DFFI_BUILDING -DUSE_SSE2 -DUSE_SSSE3 -DUSE_AVX2 -DUSE_AVXVNNI -DUSE_AVX512BW -DUSE_AVX512VNNI -DEXPORT_JS_API -DMOZ_HAS_MOZGLUE -DMOZ_SUPPORT_LEAKCHECKING -I/builds/worker/checkouts/gecko/js/src/intgemm -I/builds/worker/workspace/obj-build/js/src/intgemm -I/builds/worker/workspace/obj-build/js/src -I/builds/worker/checkouts/gecko/js/src -I/builds/worker/checkouts/gecko/third_party/gemmology -I/builds/worker/checkouts/gecko/third_party/xsimd/include -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -D_GLIBCXX_USE_CXX11_ABI=0 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -fcrash-diagnostics-dir=/builds/worker/artifacts -gdwarf-4 -O3 -fno-omit-frame-pointer -funwind-tables -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Wenum-float-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Wno-psabi -Wthread-safety -Wno-error=builtin-macro-redefined -Wno-unknown-warning-option -Werror=format -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/IntegerGemmIntrinsic.o.pp   /builds/worker/checkouts/gecko/js/src/intgemm/IntegerGemmIntrinsic.cpp
[task 2025-09-26T20:27:35.175+00:00] 20:27:35     INFO -  In file included from /builds/worker/checkouts/gecko/js/src/intgemm/IntegerGemmIntrinsic.cpp:22:
[task 2025-09-26T20:27:35.176+00:00] 20:27:35     INFO -  In file included from /builds/worker/checkouts/gecko/js/src/vm/JSContext.h:19:
[task 2025-09-26T20:27:35.176+00:00] 20:27:35     INFO -  In file included from /builds/worker/checkouts/gecko/js/src/ds/TraceableFifo.h:10:
[task 2025-09-26T20:27:35.176+00:00] 20:27:35    ERROR -  /builds/worker/checkouts/gecko/js/src/ds/Fifo.h:30:65: error: template template argument has different template parameters than its corresponding template template parameter
[task 2025-09-26T20:27:35.176+00:00] 20:27:35     INFO -     30 |           template <typename, size_t, class> class VectorType = Vector>
[task 2025-09-26T20:27:35.176+00:00] 20:27:35     INFO -        |                                                                 ^
[task 2025-09-26T20:27:35.177+00:00] 20:27:35     INFO -  /builds/worker/checkouts/gecko/js/src/vm/OffThreadPromiseRuntimeState.h:220:63: note: while checking a default template argument used here
[task 2025-09-26T20:27:35.177+00:00] 20:27:35     INFO -    220 |     Fifo<js::UniquePtr<JS::Dispatchable>, 0, SystemAllocPolicy>;
[task 2025-09-26T20:27:35.177+00:00] 20:27:35     INFO -        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
[task 2025-09-26T20:27:35.177+00:00] 20:27:35     INFO -  /builds/worker/workspace/obj-build/dist/include/js/Vector.h:30:1: note: too many template parameters in template template argument
[task 2025-09-26T20:27:35.177+00:00] 20:27:35     INFO -     30 | template <typename T, size_t MinInlineCapacity = 0,
[task 2025-09-26T20:27:35.177+00:00] 20:27:35     INFO -        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2025-09-26T20:27:35.178+00:00] 20:27:35     INFO -     31 |           class AllocPolicy = TempAllocPolicy,
[task 2025-09-26T20:27:35.178+00:00] 20:27:35     INFO -        |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2025-09-26T20:27:35.178+00:00] 20:27:35     INFO -     32 |           // Don't use this with JS::Value!  Use JS::RootedValueVector instead.
[task 2025-09-26T20:27:35.178+00:00] 20:27:35     INFO -        |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2025-09-26T20:27:35.178+00:00] 20:27:35     INFO -     33 |           typename = std::enable_if_t<!detail::TypeIsGCThing<T>::value>>
[task 2025-09-26T20:27:35.178+00:00] 20:27:35     INFO -        |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2025-09-26T20:27:35.179+00:00] 20:27:35     INFO -  /builds/worker/checkouts/gecko/js/src/ds/Fifo.h:30:11: note: previous template template parameter is here
[task 2025-09-26T20:27:35.179+00:00] 20:27:35     INFO -     30 |           template <typename, size_t, class> class VectorType = Vector>
[task 2025-09-26T20:27:35.179+00:00] 20:27:35     INFO -        |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[task 2025-09-26T20:27:35.179+00:00] 20:27:35     INFO -  In file included from /builds/worker/checkouts/gecko/js/src/intgemm/IntegerGemmIntrinsic.cpp:22:
[task 2025-09-26T20:27:35.179+00:00] 20:27:35     INFO -  In file included from /builds/worker/checkouts/gecko/js/src/vm/JSContext.h:41:
[task 2025-09-26T20:27:35.180+00:00] 20:27:35     INFO -  In file included from /builds/worker/checkouts/gecko/js/src/vm/Runtime.h:57:
[task 2025-09-26T20:27:35.180+00:00] 20:27:35    ERROR -  /builds/worker/checkouts/gecko/js/src/vm/OffThreadPromiseRuntimeState.h:292:24: error: use of undeclared identifier 'DispatchableFifo'
[task 2025-09-26T20:27:35.180+00:00] 20:27:35     INFO -    292 |   HelperThreadLockData<DispatchableFifo> failed_;
[task 2025-09-26T20:27:35.180+00:00] 20:27:35     INFO -        |                        ^
[task 2025-09-26T20:27:35.180+00:00] 20:27:35    ERROR -  /builds/worker/checkouts/gecko/js/src/vm/OffThreadPromiseRuntimeState.h:305:24: error: use of undeclared identifier 'DispatchableFifo'
[task 2025-09-26T20:27:35.180+00:00] 20:27:35     INFO -    305 |   HelperThreadLockData<DispatchableFifo> internalDispatchQueue_;
[task 2025-09-26T20:27:35.181+00:00] 20:27:35     INFO -        |                        ^
[task 2025-09-26T20:27:35.181+00:00] 20:27:35    ERROR -  /builds/worker/checkouts/gecko/js/src/vm/OffThreadPromiseRuntimeState.h:313:3: error: unknown type name 'DispatchableFifo'
[task 2025-09-26T20:27:35.181+00:00] 20:27:35     INFO -    313 |   DispatchableFifo& failed() { return failed_.ref(); }
[task 2025-09-26T20:27:35.181+00:00] 20:27:35     INFO -        |   ^
[task 2025-09-26T20:27:35.181+00:00] 20:27:35    ERROR -  /builds/worker/checkouts/gecko/js/src/vm/OffThreadPromiseRuntimeState.h:316:3: error: unknown type name 'DispatchableFifo'
[task 2025-09-26T20:27:35.181+00:00] 20:27:35     INFO -    316 |   DispatchableFifo& internalDispatchQueue() {
[task 2025-09-26T20:27:35.182+00:00] 20:27:35     INFO -        |   ^
[task 2025-09-26T20:27:35.182+00:00] 20:27:35     INFO -  5 errors generated.
[task 2025-09-26T20:27:35.182+00:00] 20:27:35    ERROR -  gmake[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:669: IntegerGemmIntrinsic.o] Error 1
[task 2025-09-26T20:27:35.182+00:00] 20:27:35     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/js/src/intgemm'
<...>
Flags: needinfo?(mgaudet)
Pushed by mgaudet@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/835d28630b78 https://hg.mozilla.org/integration/autoland/rev/1e5e073dd6fe Make Vector a parameter to ds/fifo.h r=jonco https://github.com/mozilla-firefox/firefox/commit/bc39ce492fd9 https://hg.mozilla.org/integration/autoland/rev/3188150fb2dc Support JS::Value in TraceableFifo r=jonco https://github.com/mozilla-firefox/firefox/commit/6b42c810dbe8 https://hg.mozilla.org/integration/autoland/rev/6a94b832afc9 Move ReactionRecord slots inside of class r=arai https://github.com/mozilla-firefox/firefox/commit/760bf1d82c7d https://hg.mozilla.org/integration/autoland/rev/6800e308c2fa Split CallSetup out of CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/4543e212598c https://hg.mozilla.org/integration/autoland/rev/12ea0a3b0371 Refactor CallSetup r=smaug https://github.com/mozilla-firefox/firefox/commit/8ca132be24a6 https://hg.mozilla.org/integration/autoland/rev/2381f3a5715e Add CallSetup that doesn't take a CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/c44def3ab8d8 https://hg.mozilla.org/integration/autoland/rev/4fa551748447 Add javascript.options.use_js_microtask_queue r=arai https://github.com/mozilla-firefox/firefox/commit/f46bc0e91a38 https://hg.mozilla.org/integration/autoland/rev/7b42ca68e2ad Create MaybeGetPromiseAllocationSite r=arai https://github.com/mozilla-firefox/firefox/commit/2e713592f0e0 https://hg.mozilla.org/integration/autoland/rev/8feb41ae4f13 Shell support for a JS MicroTaskQueue. r=arai https://github.com/mozilla-firefox/firefox/commit/6c8a5037d5d6 https://hg.mozilla.org/integration/autoland/rev/ecad88a0572c Gecko Support for JS Micro Task Queue r=arai,smaug,dom-worker-reviewers,asuth https://github.com/mozilla-firefox/firefox/commit/a97a6bf1c557 https://hg.mozilla.org/integration/autoland/rev/fd68ac4d7f55 Select debugger queue where required r=arai,smaug,dom-worker-reviewers,asuth

Backed out for causing hazard bustages

Pushed by mgaudet@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5dfe4289d6c3 https://hg.mozilla.org/integration/autoland/rev/8ff647e1ac84 Make Vector a parameter to ds/fifo.h r=jonco https://github.com/mozilla-firefox/firefox/commit/ff9f29a8ea20 https://hg.mozilla.org/integration/autoland/rev/88d59ea55123 Support JS::Value in TraceableFifo r=jonco https://github.com/mozilla-firefox/firefox/commit/352f25929dea https://hg.mozilla.org/integration/autoland/rev/151f889e6b96 Move ReactionRecord slots inside of class r=arai https://github.com/mozilla-firefox/firefox/commit/96a30ee4d0c0 https://hg.mozilla.org/integration/autoland/rev/2e84cc8e73d4 Split CallSetup out of CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/e0fb5fafd876 https://hg.mozilla.org/integration/autoland/rev/549c908d973a Refactor CallSetup r=smaug https://github.com/mozilla-firefox/firefox/commit/2da37ff522ef https://hg.mozilla.org/integration/autoland/rev/0cf931476ed8 Add CallSetup that doesn't take a CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/09feb13b4485 https://hg.mozilla.org/integration/autoland/rev/1c77ee3e237d Add javascript.options.use_js_microtask_queue r=arai https://github.com/mozilla-firefox/firefox/commit/24a24f72f168 https://hg.mozilla.org/integration/autoland/rev/cf0e46809ff8 Create MaybeGetPromiseAllocationSite r=arai https://github.com/mozilla-firefox/firefox/commit/9673cb68c668 https://hg.mozilla.org/integration/autoland/rev/0419402abdf6 Shell support for a JS MicroTaskQueue. r=arai https://github.com/mozilla-firefox/firefox/commit/da8b30ca2c50 https://hg.mozilla.org/integration/autoland/rev/8f1b7684874d Gecko Support for JS Micro Task Queue r=arai,smaug,dom-worker-reviewers,asuth https://github.com/mozilla-firefox/firefox/commit/25b6ec5fe1f4 https://hg.mozilla.org/integration/autoland/rev/86a95a0062ed Select debugger queue where required r=arai,smaug,dom-worker-reviewers,asuth
Pushed by abutkovits@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4258ca077fef https://hg.mozilla.org/integration/autoland/rev/24347d6b356b Revert "Bug 1983154, Bug 1977466 - Select debugger queue where required r=arai,smaug,dom-worker-reviewers,asuth" for causing Hazard bustages.
Pushed by mgaudet@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e1408b070296 https://hg.mozilla.org/integration/autoland/rev/33770e4a33f8 Make Vector a parameter to ds/fifo.h r=jonco https://github.com/mozilla-firefox/firefox/commit/201c1ed8687f https://hg.mozilla.org/integration/autoland/rev/c657229888a9 Support JS::Value in TraceableFifo r=jonco https://github.com/mozilla-firefox/firefox/commit/47190b510d90 https://hg.mozilla.org/integration/autoland/rev/ea340fc1af80 Move ReactionRecord slots inside of class r=arai https://github.com/mozilla-firefox/firefox/commit/8fd042452717 https://hg.mozilla.org/integration/autoland/rev/4f66db502da6 Split CallSetup out of CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/fa35c395d66b https://hg.mozilla.org/integration/autoland/rev/e92eacd2285e Refactor CallSetup r=smaug https://github.com/mozilla-firefox/firefox/commit/fad341dfd267 https://hg.mozilla.org/integration/autoland/rev/885eba3ddd27 Add CallSetup that doesn't take a CallbackObjectBase r=smaug https://github.com/mozilla-firefox/firefox/commit/f3e968c5ec1d https://hg.mozilla.org/integration/autoland/rev/73db2329e1e1 Add javascript.options.use_js_microtask_queue r=arai https://github.com/mozilla-firefox/firefox/commit/d8e3b23cd602 https://hg.mozilla.org/integration/autoland/rev/026e1852be23 Create MaybeGetPromiseAllocationSite r=arai https://github.com/mozilla-firefox/firefox/commit/811324ab997c https://hg.mozilla.org/integration/autoland/rev/3591dc365d0e Shell support for a JS MicroTaskQueue. r=arai https://github.com/mozilla-firefox/firefox/commit/269a06ecd851 https://hg.mozilla.org/integration/autoland/rev/6d8562306645 Gecko Support for JS Micro Task Queue r=arai,smaug,dom-worker-reviewers,asuth https://github.com/mozilla-firefox/firefox/commit/a7c16b5d07d2 https://hg.mozilla.org/integration/autoland/rev/256261661f60 Select debugger queue where required r=arai,smaug,dom-worker-reviewers,asuth
Flags: needinfo?(mgaudet)
QA Whiteboard: [qa-triage-done-c146/b145]
Regressions: 1995409
Depends on: 1997702
Depends on: 2002852
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: