/Items/Filters2 and /Items/Latest are slow on a large library #17
Loading…
Reference in a new issue
No description provided.
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?
Warm, stable across repeats, against 11 946 items:
/Items/Filters2(Shows)/Items/Latest(Shows)/Itemspage 1 (Shows)/Items/Counts/ItemsstartIndex=5000Both slow ones are on the path the web client hits when opening a library, and
both scale with library size where paging does not — the deep page is the
fastest call in the table.
Found by scanning
/mnt/media(285 movies, 289 shows, 74 music artists —~13 000 media files on a CIFS mount) with both this server and upstream
Jellyfin at the pinned commit, remote metadata and image fetchers disabled on
upstream so both were reading files only. Upstream was given the same mount
path so
MD5(UTF-16LE(path))agrees and rows compare directly.Fixed in
55d5a3c,afd47eband7dcbaa2.Measured on the same library, warm:
/Items/Filters2(Shows)/Items/Latest(Shows)/Items/Latest(Music)/Itemspage 1 (Shows)/Items/CountsThree things were wrong, and the third was the largest.
A filter read the library twice over.
/Items/Filters2read every item andthen every item's streams — a query per item, per stream kind — to answer with
the languages they declare. Upstream asks the database once, and so does this
now.
A latest list read the library to report ten of its items. Both grouped
forms read pages until what is left cannot change the answer: as many keys as
are being reported for a film, and a series' window past that for a show, which
is upstream's own cutoff.
A query aimed at one folder read the whole table. Counting what a season
holds drove from
BaseItemsand probed the ancestors per row — 56 ms an itemagainst 0.3 ms for a film, so a page of a hundred series took five seconds.
Reading the ancestors first is 50x on that count, and it is what took
/Itemson a show library from 5.5 s to 51 ms. Nothing in the issue named that endpoint;
it was the same defect seen from another side.
/Items/Countsis unchanged and now the slowest of the five.Three correctness differences turned up in the same functions and are fixed
with them:
library declared no languages at all. It declares 32 audio and 95
subtitle languages now.
und— a language a client filters by — notnothing, and the list is ordered by the name a client shows rather than by
the code it filters by.
stream hangs off, and never fills
Tagsat all.Review caught two more in the new code: a stop that counts groups is only sound
if the read is ordered the way the answer is picked, which for a film it is not
— it reads past the moment the last reported key was added now. And
Limit=0indexed off the end of an empty list.