Closed Bug 1613440 Opened 5 years ago Closed 5 years ago

Prevent new ad hoc additions of NS_NewNamedThread

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla75
Tracking Status
firefox75 --- fixed

People

(Reporter: KrisWright, Assigned: KrisWright)

References

(Blocks 4 open bugs, Regressed 1 open bug)

Details

Attachments

(1 file)

Unless there is a very specific reason not to, we want to encourage async work to go to the background thread pool (bug 1595241) instead of going into another new one-off thread. There are a lot of benefits to using this pool, and it also benefits the future scheduler to reduce our overall thread count and have them funneling into some common mechanism.

To cap the creation of new threads, we want to introduce a mechanism that deprecates new additions of NS_NewNamedThread [1]. I can see us doing this with a clang plugin and a whitelist of all the existing instances of NS_NewNamedThread.

[1] https://searchfox.org/mozilla-central/rev/3a0a8e2762821c6afc1d235b3eb3dde63ad3b01a/xpcom/threads/nsThreadUtils.h#58,64

(It would be good to remove NS_NewThread by that point, otherwise people might be tempted to use it instead of NS_NewNamedThread to get around the error.)

(In reply to Markus Stange [:mstange] from comment #1)

(It would be good to remove NS_NewThread by that point, otherwise people might be tempted to use it instead of NS_NewNamedThread to get around the error.)

This is a good point, and I think fixing bug 1539944 should be a part of this process.

Depends on: 1539944

Creates a NoNewThreadsChecker plugin that looks for the function and checks to see if it's allowed. This is still WIP and will break your build.

Blocks: clang-plugin
Assignee: nobody → kwright
Attachment #9126194 - Attachment description: Bug 1613440 - (WIP) Add new clang plugin to deprecate NS_NewNamedThread → Bug 1613440 - Add new clang plugin to deprecate NS_NewNamedThread
Status: NEW → ASSIGNED
Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/459a77fff516 Add new clang plugin to deprecate NS_NewNamedThread r=andi
Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f400f164b394 Add new clang plugin to deprecate NS_NewNamedThread r=andi
Flags: needinfo?(kwright)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
Regressions: 1618933
Regressions: 1618934
Regressions: 1619127
Blocks: 1810242
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: