forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into discord-dnd-fix
- Loading branch information
Showing
34 changed files
with
417 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Runtime; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Logging; | ||
using osu.Game.Performance; | ||
|
||
namespace osu.Desktop.Performance | ||
{ | ||
public class HighPerformanceSessionManager : IHighPerformanceSessionManager | ||
{ | ||
private GCLatencyMode originalGCMode; | ||
|
||
public IDisposable BeginSession() | ||
{ | ||
enableHighPerformanceSession(); | ||
return new InvokeOnDisposal<HighPerformanceSessionManager>(this, static m => m.disableHighPerformanceSession()); | ||
} | ||
|
||
private void enableHighPerformanceSession() | ||
{ | ||
Logger.Log("Starting high performance session"); | ||
|
||
originalGCMode = GCSettings.LatencyMode; | ||
GCSettings.LatencyMode = GCLatencyMode.LowLatency; | ||
|
||
// Without doing this, the new GC mode won't kick in until the next GC, which could be at a more noticeable point in time. | ||
GC.Collect(0); | ||
} | ||
|
||
private void disableHighPerformanceSession() | ||
{ | ||
Logger.Log("Ending high performance session"); | ||
|
||
if (GCSettings.LatencyMode == GCLatencyMode.LowLatency) | ||
GCSettings.LatencyMode = originalGCMode; | ||
|
||
// No GC.Collect() as we were already collecting at a higher frequency in the old mode. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.