mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 06:52:53 +08:00
Improve performance of imports by keeping a context hot
This commit is contained in:
parent
4e8019b313
commit
4193004fbf
@ -165,6 +165,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
private readonly object importLock = new object();
|
private readonly object importLock = new object();
|
||||||
|
|
||||||
|
private OsuDbContext importContext;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import a beatmap from an <see cref="ArchiveReader"/>.
|
/// Import a beatmap from an <see cref="ArchiveReader"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -174,7 +176,7 @@ namespace osu.Game.Beatmaps
|
|||||||
// let's only allow one concurrent import at a time for now.
|
// let's only allow one concurrent import at a time for now.
|
||||||
lock (importLock)
|
lock (importLock)
|
||||||
{
|
{
|
||||||
var context = createContext();
|
var context = importContext ?? (importContext = createContext());
|
||||||
|
|
||||||
context.Database.AutoTransactionsEnabled = false;
|
context.Database.AutoTransactionsEnabled = false;
|
||||||
|
|
||||||
@ -190,9 +192,9 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
iBeatmaps.Add(set);
|
iBeatmaps.Add(set);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
transaction.Commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user