Open PJB3005 opened 1 year ago
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Author: | PJB3005 |
---|---|
Assignees: | - |
Labels: | `area-System.Threading`, `untriaged` |
Milestone: | - |
@PJB3005 thank you for bringing this up. I've been also recently thinking about trying setting the nice values for the priority of GC threads where we also keep them on the same level as other threads on Unix. Sounds like it would make sense for the case you've mentioned too. I am assigning this to myself.
Thread.Priority should definitely set nice, since that's what most developers will expect and it's the closest concept in Linux, even if it doesn't perfectly match Windows' priorities. The documentation does say "The scheduling algorithm used to determine the order of thread execution varies with each operating system."
If not, the documentation should at least warn that it does nothing on Linux. As it is right now it's just broken.
For what it's worth, the setpriority and getpriority POSIX calls actually do set the nice value, so it's not unreasonable to use that word.
Out of the box,
Thread.Priority
does nothing on Linux. This has been discussed in another issue: #60114. The core problem mentioned there is that Linux' default scheduler policy,SCHED_OTHER
, ignores priority values. From the man page:Except, that's not the only way to influence CPU scheduling on Linux. You can also change the
nice
value:Now, nice values on Linux are not as absolute as Windows' thread priorities (according to the respective documentation), so I can understand that the behavior wouldn't be the same. But I do wonder if it makes sense to just map priority values to nice anyways?