[PR #16038] [CLOSED] Performance fixes #14504

Closed
opened 2026-02-07 07:30:52 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/16038
Author: @bridgemill-ch
Created: 1/17/2026
Status: Closed

Base: masterHead: performance-fixes


📝 Commits (9)

  • 1e73411 fix: Replace unbounded ConcurrentDictionary with IMemoryCache in DirectoryService
  • 14dad23 fix: Remove blocking async calls in LibraryManager
  • 25f872a fix: Remove blocking async calls in entity classes
  • 91110aa fix: Optimize EF Core queries in BaseItemRepository
  • 0c34c32 fix: Add missing using statements and fix StyleCop ordering
  • d650b14 fix: Remove trailing whitespace in BaseItemRepository
  • 75ecf03 fix: Restore old DirectoryService constructor for API compatibility
  • e82c3e9 fix: Address cvium review feedback - use FastConcurrentLru per TODO, remove Task.Wait, fix async patterns
  • 05c559f Add logging for PR 16038 verification

📊 Changes

13 files changed (+501 additions, -64 deletions)

View changed files

📝 Emby.Server.Implementations/Library/LibraryManager.cs (+72 -14)
📝 Jellyfin.Api/Controllers/ItemUpdateController.cs (+3 -2)
📝 Jellyfin.Api/Controllers/ItemsController.cs (+11 -5)
📝 Jellyfin.Api/Controllers/TrailersController.cs (+4 -3)
📝 Jellyfin.Server.Implementations/Item/BaseItemRepository.cs (+10 -2)
📝 MediaBrowser.Controller/Channels/Channel.cs (+45 -1)
📝 MediaBrowser.Controller/Entities/Folder.cs (+132 -1)
📝 MediaBrowser.Controller/Entities/TV/Season.cs (+60 -1)
📝 MediaBrowser.Controller/Entities/TV/Series.cs (+87 -2)
📝 MediaBrowser.Controller/Providers/DirectoryService.cs (+65 -20)
📝 MediaBrowser.Providers/MediaInfo/AudioFileProber.cs (+4 -3)
📝 MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs (+3 -3)
📝 MediaBrowser.Providers/Music/AlbumMetadataService.cs (+5 -7)

📄 Description

Title

Fix memory leaks, thread pool starvation, and optimize database queries

Description

Changes
I'm very happy to collaborate on this massive project!

Fixes unbounded memory growth in DirectoryService by replacing ConcurrentDictionary with IMemoryCache. Removes blocking async calls in LibraryManager and entity classes to prevent thread pool starvation. Optimizes EF Core queries by filtering at database level before materialization. Tested with 8+ hour overnight monitoring on 207k file library - memory stable, no crashes, no thread starvation.

Issues
Fixes #11588
Fixes #13165
Fixes #13377
Fixes #13628
Fixes #13708
Fixes #15141
Fixes #15352
Fixes #12740


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/16038 **Author:** [@bridgemill-ch](https://github.com/bridgemill-ch) **Created:** 1/17/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `performance-fixes` --- ### 📝 Commits (9) - [`1e73411`](https://github.com/jellyfin/jellyfin/commit/1e73411d0751ea9ab424b11162d19477bffba57a) fix: Replace unbounded ConcurrentDictionary with IMemoryCache in DirectoryService - [`14dad23`](https://github.com/jellyfin/jellyfin/commit/14dad23eb1640526cd7cd2fc50da6104ec3aaf9c) fix: Remove blocking async calls in LibraryManager - [`25f872a`](https://github.com/jellyfin/jellyfin/commit/25f872aafb4c933546c0f436a12c9b033912a86d) fix: Remove blocking async calls in entity classes - [`91110aa`](https://github.com/jellyfin/jellyfin/commit/91110aa06aed1d0dc7c4cbe3c2dcb0c646e20db0) fix: Optimize EF Core queries in BaseItemRepository - [`0c34c32`](https://github.com/jellyfin/jellyfin/commit/0c34c327285d0ba676a324f547f12a5af563a4a1) fix: Add missing using statements and fix StyleCop ordering - [`d650b14`](https://github.com/jellyfin/jellyfin/commit/d650b14d1bb398e45b6980ecc53f65e840a0e0ef) fix: Remove trailing whitespace in BaseItemRepository - [`75ecf03`](https://github.com/jellyfin/jellyfin/commit/75ecf0342b1e67b929aae7de3c61d1ff099349bc) fix: Restore old DirectoryService constructor for API compatibility - [`e82c3e9`](https://github.com/jellyfin/jellyfin/commit/e82c3e921aeec0b81aa15ace010426fe549513d4) fix: Address cvium review feedback - use FastConcurrentLru per TODO, remove Task.Wait, fix async patterns - [`05c559f`](https://github.com/jellyfin/jellyfin/commit/05c559f4ce81b253ffdd6ee083f1fdffadb10f59) Add logging for PR 16038 verification ### 📊 Changes **13 files changed** (+501 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Server.Implementations/Library/LibraryManager.cs` (+72 -14) 📝 `Jellyfin.Api/Controllers/ItemUpdateController.cs` (+3 -2) 📝 `Jellyfin.Api/Controllers/ItemsController.cs` (+11 -5) 📝 `Jellyfin.Api/Controllers/TrailersController.cs` (+4 -3) 📝 `Jellyfin.Server.Implementations/Item/BaseItemRepository.cs` (+10 -2) 📝 `MediaBrowser.Controller/Channels/Channel.cs` (+45 -1) 📝 `MediaBrowser.Controller/Entities/Folder.cs` (+132 -1) 📝 `MediaBrowser.Controller/Entities/TV/Season.cs` (+60 -1) 📝 `MediaBrowser.Controller/Entities/TV/Series.cs` (+87 -2) 📝 `MediaBrowser.Controller/Providers/DirectoryService.cs` (+65 -20) 📝 `MediaBrowser.Providers/MediaInfo/AudioFileProber.cs` (+4 -3) 📝 `MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs` (+3 -3) 📝 `MediaBrowser.Providers/Music/AlbumMetadataService.cs` (+5 -7) </details> ### 📄 Description ## Title Fix memory leaks, thread pool starvation, and optimize database queries ## Description **Changes** I'm very happy to collaborate on this massive project! Fixes unbounded memory growth in DirectoryService by replacing ConcurrentDictionary with IMemoryCache. Removes blocking async calls in LibraryManager and entity classes to prevent thread pool starvation. Optimizes EF Core queries by filtering at database level before materialization. Tested with 8+ hour overnight monitoring on 207k file library - memory stable, no crashes, no thread starvation. **Issues** Fixes #11588 Fixes #13165 Fixes #13377 Fixes #13628 Fixes #13708 Fixes #15141 Fixes #15352 Fixes #12740 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 07:30:52 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#14504