[Mesa-dev] [PATCH] gallium/util: don't let children of fork & exec inherit our thread affinity

Michel Dänzer michel at daenzer.net
Wed Oct 31 09:28:43 UTC 2018

On 2018-10-31 12:39 a.m., Gustaw Smolarczyk wrote:
> śr., 31 paź 2018 o 00:23 Marek Olšák <maraeo at gmail.com> napisał(a):
>> On Tue, Oct 30, 2018 at 7:11 PM Gustaw Smolarczyk <wielkiegie at gmail.com> wrote:
>>> wt., 30 paź 2018 o 23:55 Marek Olšák <maraeo at gmail.com> napisał(a):
>>>> On Tue, Oct 30, 2018 at 6:32 PM Gustaw Smolarczyk <wielkiegie at gmail.com> wrote:
>>>>> wt., 30 paź 2018, 23:01 Marek Olšák <maraeo at gmail.com>:
>>>>>> On Mon, Oct 29, 2018 at 12:43 PM Michel Dänzer <michel at daenzer.net> wrote:
>>>>>>> On 2018-10-28 11:27 a.m., Gustaw Smolarczyk wrote:
>>>>>>>> pon., 17 wrz 2018 o 18:24 Michel Dänzer <michel at daenzer.net> napisał(a):
>>>>>>>>> OTOH, only a relatively small number of games will get a significant
>>>>>>>>> benefit from the thread affinity, and the benefit will be smaller than a
>>>>>>>>> factor of 2. This cannot justify risking a performance drop of up to a
>>>>>>>>> factor of 8, no matter how small the risk.
>>>>>>>>> Therefore, the appropriate mechanism is a whitelist.
>>>>>>>> Hi,
>>>>>>>> What was the conclusion of this discussion? I don't see any
>>>>>>>> whitelist/blacklist for this feature.
>>>>>>>> I have just tested blender and it still renders on only a single CCX
>>>>>>>> on mesa from git master. Also, there is a bug report that suggests
>>>>>>>> this regressed performance in at least one game [1].
>>>>>>> I hooked up that bug report to the 18.3 blocker bug.
>>>>>>>> If you think enabling it by default is the way to go, we should also
>>>>>>>> implement a blacklist so that it can be turned off in such cases.
>>>>>>> I stand by my opinion that a white-list is appropriate, not a
>>>>>>> black-list. It's pretty much the same as mesa_glthread.
>>>>>> So you are saying that gallium multithreading show be slower than singlethreading by default.

I'm saying we cannot risk tanking performance by a factor of 2-8, under
any circumstances.

>>>>> The Ryzen optimization helps a lot of applications (mostly games) and improves their performance, 

How much is "a lot" though? Surely it's less than a factor of 2-8?

>>>> Multithreading is slower than singlethreading. You are pretty much saying that Mesa shouldn't use multithreading by default. Just think about that. NVIDIA would destroy us at all price points. I'm not that insane to disable the thread pinning by default.
>>> I have no idea what you are saying. The current implementation of
>>> multithreading doesn't work well with all applications on Ryzen, due
>>> to kernel scheduling application and gallium/winsys threads on
>>> different CCXs. However, thread pinning is not a universal solution
>>> for this problem. We can't express what we want at the moment (i.e.
>>> schedule a couple of threads next to each other, regardless of where
>>> they really are) and the current work-around of using thread
>>> affinities hurts reals applications (like Blender).
>> As far as we know, it hurts *only* Blender.

Why are you still saying that in the light of
https://bugs.freedesktop.org/108330 ?

>> Don't say "real applications" if you don't have a good list of applications.
> Is that an excuse to hurt applications you don't know about? Should we
> ban all applications that use OpenGL and not adhere to the Safe
> Threading Behavior == use OpenGL from one thread and spawn more
> threads from this thread afterwards?

Yeah, that's just being mean to application developers (which can be
affected even if the application doesn't use OpenGL directly, but via
another library it uses). Let's not compete with other drivers on that.

>>> Also, what is the most important, Blender is just a single
>>> application. Any application can have a similarly bad behavior
>>> regarding thread affinity fixing of mesa. Do you expect any
>>> application to "fix itself" for thread affinity shenanigans of the GL
>>> library?
>>> The answer is that libraries shouldn't really mess with thread
>>> affinities. If they do, there should better be a mechanism for
>>> disabling such a behavior for applications that, justifiably, expect a
>>> system-default behavior.
>> Applications can change the thread affinity. Applications can also call setenv() to disable the Mesa behavior. Users can also disable the Mesa behavior by setting an environment variable or adding a new entry into /usr/share/drirc.d/.

Mesa isn't the centre of the universe that everything else has to adapt
to. I'm honestly worried that this kind of attitude could damage the
reputation of Mesa (and AMD).

Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

More information about the mesa-dev mailing list