Closed Bug 1583964 Opened 5 years ago Closed 5 years ago

make `IsOnCurrentThread` for thread pools constant-time

Categories

(Core :: XPCOM, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

Details

Attachments

(1 file)

No description provided.

It's fairly common for clients to hold a pointer to some private thread
and then inquire about IsOnCurrentThread in debug checks. As we
migrate these private threads into some nsIEventTarget implementation
that might be running on thread pools, we need to ensure that those
IsOnCurrentThread continues to be relatively cheap. The current
implementation for thread pools is not particularly efficient.

The inefficiency comes from having to iterate over all the threads in
the pool. But there's no need to do this; we can just have each thread
set a particular thread-local variable to the thread pool it's running
on, and check the value of that thread-local variable instead.

Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3d366bfc0508
make `IsOnCurrentThread` for thread pools constant-time; r=KrisWright
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
Assignee: nobody → nfroyd
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: