mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 02:32:59 +08:00
Remove all calls to Realm.Refresh
to fix blocking overhead from subscriptions
Turns out this is not required if realm is aware of a `SynchronizationContext`. See https://github.com/realm/realm-dotnet/discussions/2775#discussioncomment-2005412 for further reading.
This commit is contained in:
parent
cab63830a1
commit
5df46d0a54
@ -46,9 +46,6 @@ namespace osu.Game.Database
|
|||||||
migrateScores(ef);
|
migrateScores(ef);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Log("Refreshing realm...", LoggingTarget.Database);
|
|
||||||
realmContextFactory.Refresh();
|
|
||||||
|
|
||||||
// Delete the database permanently.
|
// Delete the database permanently.
|
||||||
// Will cause future startups to not attempt migration.
|
// Will cause future startups to not attempt migration.
|
||||||
Logger.Log("Migration successful, deleting EF database", LoggingTarget.Database);
|
Logger.Log("Migration successful, deleting EF database", LoggingTarget.Database);
|
||||||
|
@ -61,10 +61,10 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
private readonly ThreadLocal<bool> currentThreadCanCreateContexts = new ThreadLocal<bool>();
|
private readonly ThreadLocal<bool> currentThreadCanCreateContexts = new ThreadLocal<bool>();
|
||||||
|
|
||||||
private static readonly GlobalStatistic<int> refreshes = GlobalStatistics.Get<int>(@"Realm", @"Dirty Refreshes");
|
|
||||||
private static readonly GlobalStatistic<int> contexts_created = GlobalStatistics.Get<int>(@"Realm", @"Contexts (Created)");
|
private static readonly GlobalStatistic<int> contexts_created = GlobalStatistics.Get<int>(@"Realm", @"Contexts (Created)");
|
||||||
|
|
||||||
private readonly object contextLock = new object();
|
private readonly object contextLock = new object();
|
||||||
|
|
||||||
private Realm? context;
|
private Realm? context;
|
||||||
|
|
||||||
public Realm Context
|
public Realm Context
|
||||||
@ -169,18 +169,6 @@ namespace osu.Game.Database
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Compact() => Realm.Compact(getConfiguration());
|
public bool Compact() => Realm.Compact(getConfiguration());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Perform a blocking refresh on the main realm context.
|
|
||||||
/// </summary>
|
|
||||||
public void Refresh()
|
|
||||||
{
|
|
||||||
lock (contextLock)
|
|
||||||
{
|
|
||||||
if (context?.Refresh() == true)
|
|
||||||
refreshes.Value++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Realm CreateContext()
|
public Realm CreateContext()
|
||||||
{
|
{
|
||||||
if (isDisposed)
|
if (isDisposed)
|
||||||
|
@ -351,13 +351,6 @@ namespace osu.Game
|
|||||||
FrameStatistics.ValueChanged += e => fpsDisplayVisible.Value = e.NewValue != FrameStatisticsMode.None;
|
FrameStatistics.ValueChanged += e => fpsDisplayVisible.Value = e.NewValue != FrameStatisticsMode.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
realmFactory.Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user