Closed Bug 1619641 Opened 5 years ago Closed 5 years ago

Implement a callback in JS whenever a blocking call is executed

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: bas.schouten, Assigned: lth)

References

Details

Attachments

(1 file)

When something like FutexThread::wait() is executed we want Gecko to know it can go and execute other JS code. To do this we need JS to be able to call back into Gecko to inform us a blocking call is currently in progress, and call back when it wants to resume execution.

Blocks: 1563335

Lars, I believe you were interested in doing this? :)

Flags: needinfo?(lhansen)

Well, "interested". I can for sure implement the plumbing for the callback, though it may be best if you're the one to write the code that uses it. What kind of information do you need passed along with the callback?

Flags: needinfo?(lhansen) → needinfo?(bas)

Discussing this with Bas, we are contemplating two callbacks reachable via the context, one to be called directly before the cond::wait_until() probably and returning a void* and one to be called directly after the cond::wait_until() returns, passing it the void* returned from the first. Still discussing error handling and memory management. It would be nice to avoid a malloc inside gecko, esp since we know jemalloc is not behaving well in multithreaded settings. A possibility is that the function that sets the callback passes the size of the block it needs and that SpiderMonkey carves out memory (static allocation in the futex object, or alloca, or a static array on the stack) and passes a pointer. It would MOZ_RELEASE_ASSERT that the conditions are met and we'd catch problems in testing (very easily).

Assignee: nobody → lhansen
Status: NEW → ASSIGNED
Flags: needinfo?(bas)
OS: Unspecified → All
Priority: -- → P2
Hardware: Unspecified → All

Optionally call a callback on the runtime before going into a blocking
wait and after returning from the wait.

Bas, can you see if this meets your needs? LMK, then I can put it up for review by a JS peer.

Flags: needinfo?(bas)

This looks great to me!

Flags: needinfo?(bas)
Attachment #9131169 - Attachment description: Bug 1619641 - Callbacks around blocking wait → Bug 1619641 - Callbacks around blocking wait. r?anba
Attachment #9131169 - Attachment description: Bug 1619641 - Callbacks around blocking wait. r?anba → Bug 1619641 - Callbacks around blocking wait. r=anba
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76

Does the alert below makes sense?
== Change summary for alert #25474 (as of Tue, 24 Mar 2020 04:30:58 GMT) ==

Regressions:

65% build times osx-cross asan asan-fuzzing taskcluster-c5d.4xlarge 821.46 -> 1,351.40

For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=25474

(In reply to Alexandru Ionescu :alexandrui (needinfo me) from comment #9)

Does the alert below makes sense?

It does not. This is a tiny patch to C++ code only, it should have basically non-measurable impact on compile times.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: