mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-30 23:40:40 +02:00
[Bug]: Performance Issues Due to External Storage (CIFS) and Transient Inode Values #1654
Open
opened 2026-04-24 23:53:19 +02:00 by adam
·
30 comments
No Branch/Tag Specified
master
book_tags_genres_dedupe
episode_download_fallback
Issue-4540-SortBy-StartedDate-and-FinishedDate
episode_meta_tagging
fix_authorize_race_condition
redirect_transcode_requests
progress_updated_sort
fix_ereader_socket_event
fix_change_empty_root_password
fix_podcast_session_track_index
fix_set_token
session_modal_user
localize_durations
fix_oidc_create_user
jwt_auth_refactor
fix_scanner_deleting_single_file_books
fix_mediaprogress_updatedat_2
experimental_next_client
podcast_episode_duration
episode-timestamps-clickable
book_author_secondary_sort_title
podcast_useragents
pathexists_user_access
fix_pathexists_join
book_author_secondary_sort
clean_duplicate_mediaprogress
sanitize_html_description
trix_prevent_attachments
check_path_api_fix
fix_mediaprogress_updatedat
increase_express_json_limit
fix_dockerfile_nunicode
search_episodes
audiobook_tools_update
episode_secondary_sorts
hls_stream_url_update
new_session_track_endpoint
audiobook_tools_enhancements
watcher_rescans_update
player_track_tooltip
fix_exclude_prefixes_crash
socket_item_events
fix_podcast_episode_scanner_promise
new_stats_controller
count_cache_for_userpermissions
parsing-opf-v3
validate_migration_files
fix-quick-match-all-crash
fix-chapter-end-sleep-timer
stringify_sequelize_query
remove-col-ambiguity
fix_next_prev_edit_description
details_trim_whitespace
fix_content_url_basepath
fix_logger_fatal
progress_bar_visibility
batch-edit-populate-map-details
feed_generator_updates
bookmark-modal-updates
migrate-library-item-in-scanner
migrate-new-library-items
migrate-podcasts-new-library-item-2
migrate-podcasts-new-library-item
fix-remove-episode-from-playlist
playback-session-use-new-library-item
refactor-library-item
fix-heatmap-caption
feed-episodes-upsert
share-media-player-media-session-api
remove-old-playlist
remove_old_collection_object
plugin-implementation-demo
feed_migration
refactor-feeds-from-item
fix_remove_authors_no_books
v2.17.3-fk-constraints-migration
migrations-first-upgrade
sqlite_2
feature/nuxt-target-server
waveform
sqlite
playlists
video
v2.35.1
v2.35.0
v2.34.0
v2.33.2
v2.33.1
v2.33.0
v2.32.1
v2.32.0
v2.31.0
v2.30.0
v2.29.0
v2.28.0
v2.27.0
v2.26.3
v2.26.2
v2.26.1
v2.26.0
v2.25.1
v2.25.0
v2.24.0
v2.23.0
v2.22.0
v2.21.0
v2.20.0
v2.19.5
v2.19.4
v2.19.3
v2.19.2
v2.19.1
v2.19.0
v2.18.1
v2.18.0
v2.17.7
v2.17.6
v2.17.5
v2.17.4
v2.17.3
v2.17.2
v2.17.1
v2.17.0
v2.16.2
v2.16.1
v2.16.0
v2.15.1
v2.15.0
v2.14.0
v2.13.4
v2.13.3
v2.13.2
v2.13.1
v2.13.0
v2.12.3
v2.12.2
v2.12.1
v2.12.0
v2.11.0
v2.10.1
v2.10.0
v2.9.0
v2.8.1
v2.8.0
v2.7.2
v2.7.1
v2.7.0
v2.6.0
v2.5.0
v2.4.4
v2.4.3
v2.4.2
v2.4.1
v2.4.0
v2.3.5
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.23
v2.2.22
v2.2.21
v2.2.20
v2.2.19
v2.2.18
v2.2.17
v2.2.16
v2.2.15
v2.2.14
v2.2.13
v2.2.12
v2.2.11
v2.2.10
v2.2.9
v2.2.8
v2.2.7
v2.2.6
v2.2.5
v2.2.4
v2.2.3
v2.2.2
v2.2.1
v2.2.0
v2.1.5
v2.1.4
v2.1.3
v2.1.2
v2.1.1
v2.1.0
v2.0.24
v2.0.23
v2.0.22
v2.0.21
v2.0.20
v2.0.19
v2.0.18
v2.0.17
v2.0.16
v2.0.15
v2.0.14
v2.0.13
v2.0.12
v2.0.11
v2.0.10
v2.0.9
v2.0.8
v2.0.7
v2.0.6
v2.0.5
v2.0.4
v2.0.3
v2.0.2
v2.0.1
v1.7.2
v1.7.1
v1.7.0
v1.6.0
v1.5.5
v1.5.0
v1.4.11
v1.4.9
v1.4.7
v1.4.6
v1.4.4
v1.4.2
v1.4.0
v1.4.1
v1.3.4
v1.3.3
v1.3.1
v1.2.8
v1.2.6
v1.2.5
v1.2.4
v1.2.1
v1.1.15
v1.1.14
v1.1.13
v1.1.12
v1.1.11
v1.1.10
v1.1.9
v1.1.8
v1.0.0
0.9.61-beta.0
0.9.61-beta
Labels
Clear labels
authentication
backlog
bug
chapter editor
config-issue
ebooks
encoding/embedding
enhancement
help wanted
listening sessions & progress
planned
possible plugin
progress sync
pull-request
sorting/filtering/searching
unable to reproduce
upload
users & permissions
waiting
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
adam (Adam Melkus)
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/audiobookshelf#1654
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @babatonga on GitHub (Jan 12, 2024).
Describe the issue
I've noticed that the partial scan in Audiobookshelf takes several hours to complete, and during this process, there is a high CPU load. For comparison, Plex only requires a few seconds for a similarly sized library. Both, audiobooks and Plex movies, are mounted through a CIFS mount. I perform manual partial scans after making changes.
Issue Details:
Environment:
Additional Information:
The observed behavior is significantly different from the performance exhibited by Plex in a similar setup.
The manual execution of partial scans is necessary after changes (because watcher can't watch smb shares).
The duration of the scan has increased with the size of the library; currently, I have 1952 library entries (and 125532 audio files).
Note:
Feel free to request any additional information needed to investigate this issue further.
Steps to reproduce the issue
Audiobookshelf version
v2.7.1
How are you running audiobookshelf?
Docker
@nichwall commented on GitHub (Jan 12, 2024):
I'm not sure exactly how Plex does their scans, but I think they only use file structure/names, and don't need to parse all of the metadata on files for changes. Reading the metadata tags of media files requires the transmission of the file instead of just looking at the file name and properties.
Part of the slowdown you're seeing is probably due to needing to load all of the library files into RAM to check the metadata tags. If you change your scanner settings to not look at the audio file tags at all, does that speed up the scan in ABS?
https://www.audiobookshelf.org/guides/book-scanner#book-metadata-parsing
@babatonga commented on GitHub (Jan 12, 2024):
I'll give that a shot, although Plex also processes tags. Interestingly, when I add just one new movie, Plex efficiently reads only the tags for that specific addition. However, when I add just a small audiobook with one file, the process still takes several hours. This leads me to believe that Audiobookshelf might be rereading all metadata from every audiobook during a library scan, instead of focusing solely on the new additions.
@advplyr commented on GitHub (Jan 13, 2024):
The part that takes the longest for Abs scans is the
ffprobeon each audio file. Audio files will only be probed for a library item if it is new or a change was detected.My guess is that Abs is detecting some change on all of your library items and it may be the inode value.
You can find out by enabling debug logs in the settings -> logs page. Then when running the scan a bunch of logs will come out about changes that are detected.
Here is the javascript of a log you will want to look for
and
After that log is printed this tells the scanner that a library file was changed for that library item and a full scan is done on it.
@babatonga commented on GitHub (Jan 13, 2024):
You're right. I just analysed my latest scan log (inside metadata/logs/scans/) and logexpert finds 1952 lines with the string
Library file \"path/to/audiobooks/folder\" changedand 376222 times the second log message, here the interesting parts:It's always the same three keys that got detected as changed and birthtimeMs is always 0.
@advplyr commented on GitHub (Jan 13, 2024):
Only those values are changing? Is there something with your mounted file system that is modifying the files?
@babatonga commented on GitHub (Jan 13, 2024):
I'm not aware of any changes to the files. Could this possibly be a general issue with CIFS? Alternatively, it's possible that I've chosen a somewhat suboptimal structure. The SMB storage is initially mounted directly into Unraid via CIFS (/mnt/remotes/storage), and then it's remounted within the Docker container running Audiobookshelf under /audiobooks.
@babatonga commented on GitHub (Jan 13, 2024):
I have recently disabled the 'Audio file meta tags' slider, and the last scan now took approximately 30 minutes (for 7 new audiobooks). While there is an improvement (3.5 hours with option enabled), and my folder structure
%albumartist%\%series%\%year% - %album%[ '['%series% %series-part%']']helped recognize the new books adequately, it's not as refined as with metadata tags.@advplyr commented on GitHub (Jan 13, 2024):
I think it is a coincidence that disabling audio file meta tags in library scanner settings improved the speed. This is because we are running an ffprobe on the audio files regardless of whether you are using the meta tags from ffprobe because we also get the codec, bitrate, etc. from that ffprobe.
I'm not an expert on CIFS mounts but I did set one up in my unraid a long time ago and it was so painfully slow I gave up on it.
You could do a test yourself by opening the console in unraid for Abs and run a
staton one of your book folders.Example from my unraid container:
Those times are what Abs is saying is changing between scans so if you note some times on a book then without doing anything check again later or the next day to see if they changed magically.
@babatonga commented on GitHub (Jan 13, 2024):
That's looking good so far, dates seem to be valid (that is the date I added the audiobook):
but IO Block and size have some silly values, that could be because of cifs. I will run that again after a the next scan in a few days, then we'll see if dates got changed.
I just checked the new log file (from the faster scan), and indeed, there is no entry indicating that something changed. So, it seems like a coincidence. Before the next scan, I will restart the container.
@babatonga commented on GitHub (Jan 14, 2024):
After remounting the CIFS share and restarting the Audiobookshelf container, the device and inode values changed:
Perhaps that's sufficient for Audiobookshelf to detect changes?
@advplyr commented on GitHub (Jan 14, 2024):
Yeah the inode is something Abs monitors to handle renames. In some network file systems you can configure this to use the inode value from the underlying file system instead of constructing new ones. I can't recall the specifics with that but maybe in your unraid setup you can find a setting about inode values.
@babatonga commented on GitHub (Jan 14, 2024):
There is an option for CIFS
serverinowhich enables using server-side inode numbers. Without this setting those numbers will be random. I'm currently using the plugin dlandon/unassigned.devices to handle CIFS mounts and can't set that option by myself. But I could try to create a feature request there to support that option, but the owner doesn't like adding too many configuration options, because it can get too confusing (just opened there another feature request a few days before ^^)@advplyr commented on GitHub (Jan 14, 2024):
Ah yes that is the one. The reason that this is important is because if you change the name of a folder Abs will have no way of knowing it is the same folder without having the inode as an identifier.
In Abs it would create a duplicate book and show the older one as missing. When renaming a folder the inode doesn't change so Abs can use that to check if it is the same.
@nichwall commented on GitHub (Jan 14, 2024):
Am I correct in saying the inode should be ignored if the paths match?
I remember there was a change a few months ago to check the file path instead of just the inode when the scanner was rewritten, but can't find the exact commit/discussion about the change (somewhere around 2.4.x or 2.5.x). If the file path matches and the modification time matches, could the inode just be updated to the new value without probing everything, so if the file is moved/renamed after the scan it could still use the inode? Not sure if that would complicate things later.
https://github.com/advplyr/audiobookshelf/blob/e76af3bfc2e972dbca7851c96191f1c16a10d229/server/scanner/LibraryScanner.js#L156
@advplyr commented on GitHub (Jan 14, 2024):
This is correct and could be an area of improvement. In this case from the logs it looks like the modified time is also changing which is how we determine whether someone may have updated meta tags on the audio file. When the
statwas ran in the console it did not show the modified time changed so I'm curious if resolving the inode changing issue would also resolve the modified time changing.@babatonga commented on GitHub (Jan 22, 2024):
I've reviewed my recent logs, and this time, all entries indicate that only the inode was changed:
... \" key \"ino\" changed from \"827328\" to \"1121761\"","levelName":"DEBUG","level":1}I'm not sure what went wrong during the initial scan; perhaps it was related to migrating the setup (configs / database / backup) to Unraid. Additionally, I switched from sshfs to cifs. Could the timestamps be different because of that?
Maybe an additional setting in the Library Settings could help here, allowing the user to choose whether to compare inode or "just" libraryFolderId, path, relPath, mtime, ctime and birthtime during a scan to detect changes. This setting could be used in the
checkLibraryItemDatafunction insideserver/scanner/LibraryItemScanData.jsto add the attributeinoor not to the listkeysToCompare.If the inode value is needed elsewhere, you can also set
existingLibraryItem.ino = this.ino(and save it) at the appropriate location if the setting to not use the inode is enabled. However, in my case, the value has changed several times before and has never disrupted further operations.@martinjgrunwald commented on GitHub (Feb 8, 2024):
I have been using ABS since Version 2.4 and this behavior has only happened to me recently, I believe since 2.7.0, even though I didn't change anything about my mount structure. ABS was never quite as fast as Plex but the difference used to be around the factor 5. I have about 900 audio books / 50.000 audio files. That takes around 20s for Plex and it used to take about a minute for ABS. Now the time for ABS has increased to around 40 minutes. I can't say for sure if the CPU usage was as high as it is now since a spike for one minute would not have been as obvious as it is now when the scan takes that long
@babatonga commented on GitHub (Feb 8, 2024):
I tested the entire setup locally by removing 'ino' from 'keysToCompare', and it worked. However, since I had several TB of free space on my unraid array, I moved all my audio files there and now only use external storage for mirroring/backing up the files. The performance has significantly improved, not just in scanning but also in response time when playing the audiobooks. So, personally, I consider the issue resolved. However, perhaps introducing a setting to disable/update inodes during scanning could help circumvent problems with inconsistent inode values.
@martinjgrunwald commented on GitHub (Feb 8, 2024):
Where exactly did you remove 'ino' from 'keysToCompare'?
@advplyr commented on GitHub (Feb 8, 2024):
That could cause more confusion since the file watcher uses the inode to check if items are the same in order to detect filename changes. Do you happen to know why you weren't/aren't able to update the filesystem to use static unique inodes on files?
@babatonga commented on GitHub (Feb 8, 2024):
There seemed to be issues with stale file handles, which is why the option for that is not included in 'unassigned.devices' (https://github.com/dlandon/unassigned.devices/issues/99). One could probably mount the whole thing manually without the plugin, but I didn't test that anymore since I switched to local storage.
@advplyr commented on GitHub (Feb 8, 2024):
Hm okay, I'm not sure I understand the response to your FR there. I'll backlog this issue for now if/until some more users come forward with being unable to use serverino
@martinjgrunwald commented on GitHub (Feb 19, 2024):
I am at a bit of a loss here. What can I do to avoid these long scan times and massive performance surges when scanning my library? My log is also full of notices that only 'ino' changed. Again, this wasn't always the case. Also, I rely on having my audiobooks on a different system than ABS, having them on the same one is not an option for me
@babatonga commented on GitHub (Feb 19, 2024):
If you rely on external volumes, it's best to ensure that the inode values of the server providing the volume or other static ones are used. For CIFS, there's an option called "serverino" for this purpose. However, I'm not aware of such an option for sshfs; it seems it doesn't exist for all external mount types. If that's not possible, then we'll have to wait until multiple users report this issue and the developers find a solution.
@JohanPotgieter commented on GitHub (Feb 24, 2024):
I have the same issue of very long scan times since version 2.7. In the past I could add a few books and the scan would be done in 30 seconds. Now it takes hours. My ABS is run on docker and mounts a external NTFS volume. My setup has not changed in any way.
@advplyr commented on GitHub (Mar 27, 2024):
Abs relies on your file system having static inode values. I'm not sure of another way to handle renamed files, we need a way to determine that it is the same file after a rename.
@sydlexius commented on GitHub (Apr 17, 2024):
I take it using file hashes/checksums/fingerprints are out of the question?
@aureateflux commented on GitHub (Jun 19, 2024):
I know this is a bit late, but I noticed that @babatonga's OS is Unraid. I use Unraid as well, and when I was setting up backups I came across this support thread on setting up Borgmatic for Unraid.
In that thread it notes that for Borg to work properly, you need to use mtime instead of inode:
This is literally the only place I've seen this mentioned—despite multiple very deep dives into the topic, I've never found any other corroboration of this claim. But if true, it definitely explains the longer scan times on Unraid or similar OSes.
@advplyr commented on GitHub (Jun 19, 2024):
I'm not sure what Borgmatic is but it is not true that Unraid does not have persistent inode values. Maybe they are talking about something specific within Unraid.
I use Unraid along with many users and have persistent inode values
@aureateflux commented on GitHub (Jun 19, 2024):
Borgmatic is an automation wrapper for Borg backup.
And yeah, that's why I made sure to point out I've never seen that claim anywhere else.