Asynchronous Folder Thumbnailing
See original GitHub issueAt the moment non-cached folder thumbnails are not received asynchronously, but rather a single database query is sent for every single folder synchronously, and only then the directory listing (gallery) is eventually built when everything else is already available. Therefore the availability of the directory listing (gallery) itself is delayed until a thumbnail was received for every single folder, which can result in the whole application becoming unavailable while these queries are running on particularly large folders or subfolders. (tested 700 subfolders, takes minutes!)
It would be better to initially build the directory listing (gallery) with blank folder thumbnails for it to become available fast, which are then filled in with actual folder thumbnails asynchronously, like it is already done when viewing folders containing only images (not subfolders/subfolders & images). Like for images, there should also be an option that only folder thumbnails are received for the immediate visible folders (lazy image rendering)
This is what is currently happening BEFORE the directory listing is built (with the loading bar filling on top of the page):
query: SELECT "media"."id" AS "media_id", "media"."name" AS "media_name", "directory"."name" AS "directory_name", "directory"."path" AS "directory_path", "directory"."id" AS "directory_id" FROM "media_entity" "media" INNER JOIN "directory_entity" "directory" ON "directory"."id"="media"."directoryId" WHERE ("media"."directoryId" = ? OR "directory"."path" GLOB ?) ORDER BY LENGTH("directory"."path") DESC, "media"."metadataRating" DESC, "media"."metadataCreationdate" DESC LIMIT 1 -- PARAMETERS: [3380,"Dir1/*"]
query: SELECT "media"."id" AS "media_id", "media"."name" AS "media_name", "directory"."name" AS "directory_name", "directory"."path" AS "directory_path", "directory"."id" AS "directory_id" FROM "media_entity" "media" INNER JOIN "directory_entity" "directory" ON "directory"."id"="media"."directoryId" WHERE ("media"."directoryId" = ? OR "directory"."path" GLOB ?) ORDER BY LENGTH("directory"."path") DESC, "media"."metadataRating" DESC, "media"."metadataCreationdate" DESC LIMIT 1 -- PARAMETERS: [3381,"Dir2/*"]
[…] x number of subfolders in navigated directory
I, therefore, propose the directory listing (gallery) is built immediately with blank folder thumbnails, which are then exchanged for actual folder thumbnails with the above queries running asynchronously in the background. The unfinished queries should also be cleared from the asynchronous queue when the user navigates away from the folder before all thumbnails were built, instead of continuing to run in the background and eat up database resources (as it is currently happening).
P.S. I have tested this on a project with all folders pre-indexed and pre-thumbnailed on an SSD, so there should be no further bottlenecks apart from these synchronous thumbnailing queries.
P.P.S I have run further testing and can confirm that these queries, receiving the folder thumbnails from the database, are the bottleneck here. If I let the particular function return “null” on every requested folder thumbnail, the directory listing becomes available instantly with blank thumbnails even on folders with 700+ subfolders.
This might also be relevant for #299
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (12 by maintainers)
Top GitHub Comments
776c8e8 introduces a column to store the directory previews. This should speed up the listing. (not first time ever listing will be still slow. assigning preview is lazy. They are assigned only when they are needed)
nightly should have it already