[RunnerManager] Don't mess with ThreadWeaver thread count
ClosedPublic

Authored by broulik on Dec 7 2017, 2:21 PM.

Details

Summary

We query Solid for processors causing a ton of processing to be done just to get the number of CPUs and then some magic math to determin the thread count. ThreadWeaver already does everything for us at significantly less performance penalty.

Test Plan

It spent 30ms doing this on startup, now it's like 0.05ms

ThreadWeaver has essentially the same logic already. I just set the cap to be /2 of it to keep the old behavior (which I don't know the reason for)

Diff Detail

Repository
R308 KRunner
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Dec 7 2017, 2:21 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 7 2017, 2:21 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
broulik requested review of this revision.Dec 7 2017, 2:21 PM
Restricted Application added a project: Plasma. · View Herald TranscriptDec 7 2017, 2:28 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik added inline comments.Dec 7 2017, 2:28 PM
src/runnermanager.cpp
107

Or should we keep this weird logic and substitute numProcs for idealThreadCount?

davidedmundson added inline comments.
src/runnermanager.cpp
98–99

Threadweaver defaults to
inventoryMax(qMax(4, 2 * QThread::idealThreadCount()))

At which point we basically have written:

if( X > 2X )

which is never going to happen.

Frankly I'd say let threadweaver do its own thing and not try meddling with it.

sitter added a subscriber: sitter.Dec 7 2017, 2:53 PM

It seems to me the only reason we have custom code to set the max count is because of that maxThreads config entry. An entry for which I can't see any UI backing, so it's borderline usless to begin with. The qMin then destroys any remaining use that entry may have head as we basically discard whatever was configured anyway unless it somewhat conforms to the hardcoded notion of how many threads make sense. So, I can't force a given thread count anyway.

I for one, would do away with the thread count twiddling and simply defer to whatever threadweaver says makes sense. Perhaps I am missing something though.

broulik updated this revision to Diff 23616.Dec 7 2017, 2:59 PM
broulik retitled this revision from [RunnerManager] Use QThread::idealThreadCount() instead of going through Solid to [RunnerManager] Don't mess with ThreadWeaver thread count.
broulik edited the summary of this revision. (Show Details)
broulik edited the test plan for this revision. (Show Details)
davidedmundson accepted this revision.Dec 7 2017, 3:03 PM
This revision is now accepted and ready to land.Dec 7 2017, 3:03 PM
sitter accepted this revision.Dec 7 2017, 3:25 PM

I love it

This revision was automatically updated to reflect the committed changes.