From 1007f242002b77db50e004a5a937395fe60f9289 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 Sep 2013 22:08:18 -0400 Subject: reduce task allocations by making IBN api synchronous --- .../Library/LibraryManager.cs | 121 ++++----------------- 1 file changed, 21 insertions(+), 100 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs') diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 602f81c33..10fc8a586 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -590,144 +590,60 @@ namespace MediaBrowser.Server.Implementations.Library /// Gets a Person /// /// The name. - /// if set to true [allow slow providers]. - /// Task{Person}. - public Task GetPerson(string name, bool allowSlowProviders = false) - { - return GetPerson(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets a Person - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [force creation]. /// Task{Person}. - private Task GetPerson(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) + public Person GetPerson(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.PeoplePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.PeoplePath, name); } /// /// Gets a Studio /// /// The name. - /// if set to true [allow slow providers]. - /// Task{Studio}. - public Task GetStudio(string name, bool allowSlowProviders = false) - { - return GetStudio(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the studio. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. /// Task{Studio}. - internal Task GetStudio(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) + public Studio GetStudio(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.StudioPath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.StudioPath, name); } /// /// Gets a Genre /// /// The name. - /// if set to true [allow slow providers]. - /// Task{Genre}. - public Task GetGenre(string name, bool allowSlowProviders = false) - { - return GetGenre(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the genre. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. /// Task{Genre}. - internal Task GetGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) + public Genre GetGenre(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.GenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.GenrePath, name); } /// /// Gets the genre. /// /// The name. - /// if set to true [allow slow providers]. /// Task{MusicGenre}. - public Task GetMusicGenre(string name, bool allowSlowProviders = false) + public MusicGenre GetMusicGenre(string name) { - return GetMusicGenre(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the music genre. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. - /// Task{MusicGenre}. - internal Task GetMusicGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) - { - return GetItemByName(ConfigurationManager.ApplicationPaths.MusicGenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.MusicGenrePath, name); } /// /// Gets the game genre. /// /// The name. - /// if set to true [allow slow providers]. /// Task{GameGenre}. - public Task GetGameGenre(string name, bool allowSlowProviders = false) + public GameGenre GetGameGenre(string name) { - return GetGameGenre(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the game genre. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [refresh metadata]. - /// Task{GameGenre}. - internal Task GetGameGenre(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) - { - return GetItemByName(ConfigurationManager.ApplicationPaths.GameGenrePath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.GameGenrePath, name); } /// /// Gets a Genre /// /// The name. - /// if set to true [allow slow providers]. /// Task{Genre}. - public Task GetArtist(string name, bool allowSlowProviders = false) + public Artist GetArtist(string name) { - return GetArtist(name, CancellationToken.None, allowSlowProviders); - } - - /// - /// Gets the artist. - /// - /// The name. - /// The cancellation token. - /// if set to true [allow slow providers]. - /// if set to true [force creation]. - /// Task{Artist}. - internal Task GetArtist(string name, CancellationToken cancellationToken, bool allowSlowProviders = false, bool refreshMetadata = false) - { - return GetItemByName(ConfigurationManager.ApplicationPaths.ArtistsPath, name, cancellationToken, allowSlowProviders, refreshMetadata); + return GetItemByName(ConfigurationManager.ApplicationPaths.ArtistsPath, name); } /// @@ -739,17 +655,16 @@ namespace MediaBrowser.Server.Implementations.Library /// Gets a Year /// /// The value. - /// if set to true [allow slow providers]. /// Task{Year}. /// - public Task GetYear(int value, bool allowSlowProviders = false) + public Year GetYear(int value) { if (value <= 0) { throw new ArgumentOutOfRangeException(); } - return GetItemByName(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture), CancellationToken.None, allowSlowProviders); + return GetItemByName(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture)); } /// @@ -940,7 +855,9 @@ namespace MediaBrowser.Server.Implementations.Library try { - await GetPerson(currentPerson.Name, cancellationToken, true, true).ConfigureAwait(false); + var item = GetPerson(currentPerson.Name); + + await item.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (IOException ex) { @@ -964,6 +881,10 @@ namespace MediaBrowser.Server.Implementations.Library progress.Report(100); _logger.Info("People validation complete"); + + // Bad practice, i know. But we keep a lot in memory, unfortunately. + GC.Collect(2, GCCollectionMode.Forced, true); + GC.Collect(2, GCCollectionMode.Forced, true); } /// -- cgit v1.2.3