mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Documents the SSD content setting
Adds the user manual entry, API examples, and ADR 0019 describing the scope and tradeoffs of parallel scan reads.
This commit is contained in:
1 parent
811addf8d4
commit
fc800afe03
6 files changed
+85
No files matched your search
@@ -51,6 +51,7 @@ Open the Libraries management page, choose to add a library, and fill in the for
|
||||
| Download metadata from the web | on | Whether Lumina may look up the metadata of the items online. This only has an effect when a metadata provider is enabled for the library (see [Plugins](../plugins/index.md)). |
|
||||
| Save metadata in media directories | off | Whether the metadata Lumina fetches is also written next to your media files, so other tools can read it. This is the one option that writes into your media folders. |
|
||||
| Skip unchanged directories during scan | off | An opt-in speedup that skips folders whose own last-modified time has not changed since the last scan. Editing the contents of an existing file in place, without adding, removing or renaming anything in that folder, leaves the folder's time untouched, so that edit can be missed while it is on. |
|
||||
| Content is on SSD | off | Whether the folders of this library are stored on a solid state drive. When on, the file discovery and content hashing stages read several files at the same time, which is faster on solid state drives. Leave it off for mechanical hard drives, where reading files in parallel can slow the scan down. |
|
||||
| Track consumption progress | the type default | Whether the latest playback or reading position of the library's items is remembered, so a user can resume where they left off. |
|
||||
| Completion threshold | the type default | The percentage of an item that must be consumed for a stopped session to be recorded as completed. Empty means completion is recorded only when it is reported explicitly. |
|
||||
| Path template | the type's ideal structure | Tells Lumina how your folders are arranged on disk. Unless you customize it, it holds the default template of the library type, which is exactly the structure Lumina expects. Optional, and explained in full below. |
|
||||
@@ -119,6 +120,8 @@ Creating a library only records where the media lives. To actually read it, you
|
||||
|
||||
Lumina is designed to be efficient and performant. The first scan of a library reads and indexes everything it finds, so it is the slowest one. Every scan after that compares what is on disk against the previous scan and only processes what is new or changed, so it is normally much faster. How long any scan takes also depends on what is enabled for the library: metadata and artwork providers that fetch data from the web add network time on top of reading the files, and they do it only for the items that need it.
|
||||
|
||||
How the scan reads the files depends on the hardware that stores them. A library whose content is on a solid state drive can discover and hash several files at the same time, so turn on **Content is on SSD** for it. A library on a mechanical hard drive should keep that setting off, because parallel reads make the drive seek back and forth and can make the scan slower. Metadata extraction and artwork resolution still read the files one at a time; this setting only changes file discovery and content hashing.
|
||||
|
||||
Scans run on the server in the background, so once one starts you can close the browser and come back later.
|
||||
|
||||
While a scan is running, its progress is shown live: how far along it is overall, how many items it has processed, and the operation it is currently on. A scan is queued before it starts, then runs, and ends up finished, cancelled or failed. You can cancel a running scan at any time, for one library or for all of them.
|
||||
@@ -190,6 +193,7 @@ These are per user settings, each user changes their own from the settings page
|
||||
|
||||
- **`Save metadata in media directories` writes into your media folders.** It is off by default; turn it on only if you want metadata files to accompany your media.
|
||||
- **`Skip unchanged directories during scan` can miss in-place edits.** It trusts each folder's own last-modified time, so editing the contents of an existing file without adding, removing or renaming anything in its folder leaves the folder unchanged and it gets skipped. Adding, removing or renaming a file does change the folder, and is still seen.
|
||||
- **`Content is on SSD` changes how file discovery and content hashing read files.** Turn it on only when the folders of the library really are on a solid state drive. On a mechanical hard drive, parallel reads can make those stages slower than sequential ones.
|
||||
- **`Locked` blocks everything.** A locked library is not scanned and not updated, including by the scheduler.
|
||||
- **`Disabled` hides the library.** A disabled library is neither shown on the dashboard nor touched.
|
||||
- **Deleting a library removes Lumina's catalogue for it.** The files remain, but the metadata and artwork Lumina held for that library do not. Consumption history and resume points are kept as records of what was consumed. The history shows the items as unavailable until you delete it. **Remove from continue watching** removes every resume point of the selected user, not only the ones from the deleted library.
|
||||
|
||||
@@ -65,6 +65,7 @@ POST api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": []
|
||||
@@ -92,6 +93,7 @@ POST api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
@@ -130,6 +132,7 @@ GET api/v1/libraries
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
@@ -169,6 +172,7 @@ GET api/v1/libraries/enabled
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
@@ -207,6 +211,7 @@ GET api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
@@ -238,6 +243,7 @@ PUT api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": []
|
||||
@@ -265,6 +271,7 @@ PUT api/v1/libraries/{id}
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [],
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
# Architecture Decision Record (ADR): 0019 - SSD Aware Read Parallelism During Media Library Scans
|
||||
|
||||
## Status
|
||||
|
||||
**Accepted** (2026-10-30)
|
||||
|
||||
## Context
|
||||
|
||||
A media library scan performs two kinds of file system reads. Discovery reads directory entries and file metadata, and hashing samples file contents. Their throughput depends on the storage medium. A solid state drive serves concurrent reads with little penalty, while a mechanical hard drive pays a seek for every position change, so concurrent reads can reduce its throughput.
|
||||
|
||||
Lumina cannot determine the storage medium reliably. Drive type queries are platform specific, and they are unreliable for network, virtual, and removable volumes. The scan therefore needs an explicit input instead of an automatic guess.
|
||||
|
||||
Not every scan stage performs bulk local reads. Audio metadata extraction parses tag blocks, and metadata and artwork enrichment call remote providers. Those stages have their own constraints, which are part of this decision.
|
||||
|
||||
## Decision
|
||||
|
||||
Add an `IsContentOnSsd` boolean to the `Library` aggregate, **off by default**. It is stored in the `Libraries` table with a default value of `false` and exposed through the library form and API contracts.
|
||||
|
||||
The setting controls read parallelism in the two stages that perform bulk local reads:
|
||||
|
||||
- **File system discovery**: the book and music discovery jobs read the sizes and last write times of the files of each directory in parallel when the option is on, and sequentially when it is off. Discovered files and directory fingerprints are still merged and written to the repositories sequentially, because the repositories are not thread-safe.
|
||||
- **File hashing**: `MediaLibraryScanHashJob` reads `IsContentOnSsd` without loading the content location or path template graph, and passes it to `IFileHashService.HashFilesAsync`. The service uses `MaxDegreeOfParallelism = Environment.ProcessorCount` when the option is on, and `MaxDegreeOfParallelism = 1` when it is off.
|
||||
|
||||
The following stages keep their current sequencing:
|
||||
|
||||
- **Audio metadata extraction**: extraction and persistence are interleaved on one `IUnitOfWork` and `DbContext`, which is not thread-safe. Parallelizing it requires a bounded producer and consumer split, with extraction on worker threads and all repository writes on one thread.
|
||||
- **Metadata and artwork enrichment**: these stages are network bound, and the providers already have process-wide request throttles. Item level parallelism would mostly queue on those throttles, and it is a provider concurrency concern rather than a storage medium concern.
|
||||
|
||||
The setting does not change the stored catalogue or the result of a scan. It only changes how discovery and hashing read the files, so a change takes effect on the next scan and never requires a rehash of unchanged files.
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive Outcomes
|
||||
|
||||
| Aspect | Benefit |
|
||||
|---|---|
|
||||
| Explicit choice | The scan never guesses the storage medium from platform specific or unreliable drive queries |
|
||||
| Off by default | Existing libraries keep sequential reads, and mechanical drives are never slowed down by an upgrade |
|
||||
| Bounded memory | Parallel reads are merged before batching, so staging results and directory fingerprints keep their existing batch size and memory profile |
|
||||
| Cheap hashing lookup | The hashing job reads only the scalar setting, without tracking the library or loading its navigation properties |
|
||||
|
||||
### Risks and Tradeoffs
|
||||
|
||||
| Risk | Mitigation Strategy |
|
||||
|---|---|
|
||||
| A user enables the option on a mechanical drive | The option label and description state that it is meant for solid state drives, and the manual repeats the warning |
|
||||
| The option can be forgotten after moving a library to another drive | It is editable on the existing library, and it takes effect on the next scan |
|
||||
| The content locations of one library can be mixed across solid state and mechanical drives | The option describes the library as a whole. Keep it off when any content location is on a mechanical drive, or split the locations into separate libraries when the difference matters |
|
||||
| Parallel metadata reads on a directory with many files allocate the metadata array for that directory | Only one directory is processed at a time, and the array is merged into the existing bounded staging batches as soon as it is ready |
|
||||
| Metadata extraction and enrichment do not benefit from the setting | They are documented as separate stages with their own constraints, and the option description names only file discovery and content hashing |
|
||||
| Discovery reads and hashing run in parallel, but enrichment still waits on provider throttles | The setting is scoped to local read throughput and does not claim to speed up network bound stages |
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
### 1. Always read in parallel
|
||||
|
||||
Keep the previous `Environment.ProcessorCount` behavior for every scan and do not expose a setting.
|
||||
|
||||
**Rejected**: mechanical drives can become slower with concurrent reads.
|
||||
|
||||
### 2. Detect the storage medium automatically
|
||||
|
||||
Query the operating system for the drive type of each content location and choose the parallelism accordingly.
|
||||
|
||||
**Rejected**: the detection is platform specific, unreliable for network and virtual volumes, and would hide the choice from the user.
|
||||
|
||||
### 3. Parallelize metadata extraction and enrichment under the same setting
|
||||
|
||||
Use the same flag to parallelize audio metadata extraction, metadata enrichment, and artwork resolution.
|
||||
|
||||
**Rejected for now**: extraction needs a bounded producer and consumer refactor around the non-thread-safe `DbContext`, and enrichment is network bound behind process-wide provider throttles. Both are separate concerns from the read behavior of the storage medium.
|
||||
@@ -14,6 +14,7 @@ Content-Type: application/json
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [
|
||||
|
||||
@@ -16,6 +16,7 @@ Content-Type: application/json
|
||||
"canDownloadMetadataFromWeb": true,
|
||||
"shouldSaveMetadataInMediaDirectories": true,
|
||||
"shouldSkipUnchangedDirectoriesDuringScan": true,
|
||||
"isContentOnSsd": false,
|
||||
"shouldTrackConsumptionProgress": true,
|
||||
"completionThresholdPercentage": 100,
|
||||
"pathTemplateParts": [
|
||||
|
||||
Reference in new issue
Block a user