[PR #13749] [MERGED] 2x faster library.db migration, reduced memory pressure #13691

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

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/13749
Author: @ferferga
Created: 3/22/2025
Status: Merged
Merged: 3/23/2025
Merged by: @crobibero

Base: masterHead: performant-librarydb-migration


📝 Commits (1)

  • 0df8492 Clear dictionaries when not needed, use set for finding existing base items

📊 Changes

1 file changed (+8 additions, -2 deletions)

View changed files

📝 Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs (+8 -2)

📄 Description

This PR reduces the migration from 08:57 minutes to 04:26 in my Raspberry Pi. The main performance speedup is achieved by querying all base item ids into a HashSet instead of doing queries inside the loop.

Also, clearing the collections when they're no longer needed reduced the average RAM usage while migrating (basic GC seems to trigger between steps).

I believe this could be further optimized with some parallelization, but I think this is good enough for now and I'm not sure I'm going to have time for testing before release on April.


🔄 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/13749 **Author:** [@ferferga](https://github.com/ferferga) **Created:** 3/22/2025 **Status:** ✅ Merged **Merged:** 3/23/2025 **Merged by:** [@crobibero](https://github.com/crobibero) **Base:** `master` ← **Head:** `performant-librarydb-migration` --- ### 📝 Commits (1) - [`0df8492`](https://github.com/jellyfin/jellyfin/commit/0df849246acacafb69cf421ddeb7cb752061b120) Clear dictionaries when not needed, use set for finding existing base items ### 📊 Changes **1 file changed** (+8 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs` (+8 -2) </details> ### 📄 Description This PR reduces the migration from 08:57 minutes to 04:26 in my Raspberry Pi. The main performance speedup is achieved by querying all base item ids into a HashSet instead of doing queries inside the loop. Also, clearing the collections when they're no longer needed reduced the average RAM usage while migrating (basic GC seems to trigger between steps). I believe this could be further optimized with some parallelization, but I think this is good enough for now and I'm not sure I'm going to have time for testing before release on April. --- <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:17:28 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#13691