Implement a callback in JS whenever a blocking call is executed
Categories
(Core :: JavaScript Engine, task, P2)
Tracking
()
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.
Reporter | ||
Comment 1•5 years ago
|
||
Lars, I believe you were interested in doing this? :)
Assignee | ||
Comment 2•5 years ago
|
||
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?
Assignee | ||
Comment 3•5 years ago
•
|
||
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 | ||
Comment 4•5 years ago
|
||
Optionally call a callback on the runtime before going into a blocking
wait and after returning from the wait.
Assignee | ||
Comment 5•5 years ago
|
||
Bas, can you see if this meets your needs? LMK, then I can put it up for review by a JS peer.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 8•5 years ago
|
||
bugherder |
Comment 9•5 years ago
|
||
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
Assignee | ||
Comment 10•5 years ago
|
||
(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.
Description
•