Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set process priority of framework window to high when focused #6104

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

peppy
Copy link
Member

@peppy peppy commented Jan 4, 2024

This is something we do on osu!stable and has large gains (for some users) on desktop systems, especially when shared with other heavy applications.

Tested on windows and macOS. Windows works as expected, macOS fails due to lack of permissions. Would appreciate linux testing.

If deemed more appropriate, can be moved to WindowsGameHost.

This is something we do on osu!stable and has large gains on desktop systems, especially when shared with other heavy applications.
@Susko3
Copy link
Member

Susko3 commented Jan 4, 2024

Have you considered how this may affect headless testing? HeadlessGameHost derives from DesktopGameHost and is considered to be active by default. Tests probably shouldn't be using high priority.

@bdach
Copy link
Collaborator

bdach commented Jan 4, 2024

I'm not sure it realistically matters until proven otherwise. Do you have some specific concern in mind?

@Susko3
Copy link
Member

Susko3 commented Jan 4, 2024

My concerns mostly come from the tone of the documentation: "Use extreme care when specifying High for the process's priority class [...]"
And this affecting headless tests being a "hidden" change.

I've just run the full framework test suite and haven't noticed any slowdowns on my machine, so it's probably fine.

@bdach bdach self-requested a review January 4, 2024 17:54
@bdach
Copy link
Collaborator

bdach commented Jan 4, 2024

Linux also fails on lack of permissions (only when attempting to set to high).

System.ComponentModel.Win32Exception (13): Permission denied
   at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
   at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
   at osu.Framework.Platform.DesktopGameHost.setGamePriority(Boolean active) in /home/dachb/Documents/opensource/osu-framework/osu.Framework/Platform/DesktopGameHost.cs:line 133

bdach
bdach previously approved these changes Jan 4, 2024
Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems probably fine to me. Let's see how this pans out.

@peppy your call on whether you want to address the tests concern brought up above.

@peppy
Copy link
Member Author

peppy commented Jan 4, 2024

i think it might be best to, but hesitant because I'm not sure how to structure it without thinking for more than a few seconds.

@bdach
Copy link
Collaborator

bdach commented Jan 4, 2024

Probably make setGamePriority() virtual and suppress in the headless impl? Bit dirty but at this point... stuff like that already exists, i.e.

protected override void DrawFrame()
{
//we can't draw.
}

That, or move to WindowsGameHost as proposed in the OP, as it sure looks like it's not gonna work anywhere else anyway.

@bdach bdach enabled auto-merge January 8, 2024 07:48
@bdach bdach merged commit 6f99a96 into ppy:master Jan 8, 2024
13 checks passed
@peppy peppy deleted the process-priority branch January 17, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants