Raise the image cache size so a large zone view fits in it - #11295
Raise the image cache size so a large zone view fits in it#11295liamiak wants to merge 1 commit into
Conversation
056a5a7 to
a7105d9
Compare
|
thanks, interesting ideas but rather large: |
9efe953 to
c11667f
Compare
|
Force-pushed a rewrite of this branch — "rather large" was fair, and I wanted to re-review It is now five commits, each one mechanism, each building and passing the desktop test suite Instrumenting it changed the PR rather than just documenting it. I had assumed the cost was That also let me delete things rather than add them. Gone since you last looked:
Net effect is one fewer file touched than the version you commented on, and no new user Two things I would rather flag than have you find:
|
|
good call, that will surely help |
|
Also worth noting Nr. 5 is related to a previous attempt: #7838 |
|
Thanks — that pointer led somewhere I didn't expect. Reading #7838, the concern tehdiplomat raised there turns out not to be specific to that PR. Desktop's on-demand fetcher has never handled rate limiting at all: On the constraint itself, I went looking and found That said, automatic versus user-initiated is your call, not mine — if you'd rather pre-caching stayed something the player asks for, say so and I'll drop commit 5. The measured win in this PR is the rendering work; the fetching commit is the least evidenced part of it. |
c11667f to
98a02b5
Compare
|
Force-pushed this down to one commit, 13 lines. Your first note — that it was large and would need a GUI dev to comb through — turned out to be the most useful thing said about it. Re-measuring against current master (nothing upstream has touched these files in 379 commits, and it rebased clean), I had the causation wrong. I told you ~77% of a reopen was re-rendering card faces and that caching those renders was the fix. The re-rendering was real, but it was a symptom: the 400-entry cap cannot hold even one 500-card view, so the scaled copies were evicted and the faces had to be redrawn. Raise the cap, the scaled copies survive, and the re-rendering stops on its own. Everything after the first render goes 17,890ms → 4,959ms from the cap alone. Caching the renders as well takes it to 1,722ms — but holds one full 488x680 image per card, about +550MB of heap against +40MB for this. That is a poor trade for the one remaining case, and it needs a bounded design before I would send it. The rest is parked rather than dropped. The render cache needs that memory question answered; commits 3 and 5 I still have no measurement for, which is also the honest answer to the pre-caching question I asked you and you never needed to answer. If any of them are worth reviving, I would rather bring each back on its own with its own number. |
Opening a large zone view - most visibly the library during a tutor search - froze the UI for seconds, and froze it again on every sort, close and reopen. The cache is capped at 400 entries while a single large zone view needs two per card: the decoded original and the scaled copy the panel paints. A 500-card library therefore evicted everything it had just loaded and rebuilt the whole view on every refresh. 400 was never a considered choice for this workload, it is just what this preference has always defaulted to, so treat that exact value as unset and use 1500; any other value is one somebody chose and is left alone. Also switch to soft values so memory pressure rather than entry count is what ultimately evicts, which is what this class already documented itself as doing. Measured on a 500-card library with no images downloaded: reopening the view cost ~1.8s and re-requesting at a different size ~4.5s, both now ~1ms. Costs about 40MB of heap on that measurement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
98a02b5 to
6e6dfc5
Compare
Fixes the freeze when opening a large zone view — most visibly the library during a tutor
search. Sorting, closing and reopening it froze again each time.
Cause
ImageCacheis capped at 400 entries, but a single large zone view needs two per card: thedecoded original and the scaled copy the panel paints. A 500-card library therefore evicts
everything it just loaded and rebuilds the whole view on every refresh.
400 was never a considered choice for this workload — it is just what
UI_IMAGE_CACHE_MAXIMUMhas always defaulted to. This treats that exact value as unset and uses 1500; any other value
is one somebody chose and is left alone. It also switches to soft values, so memory pressure
rather than entry count is what ultimately evicts, which is what this class already documented
itself as doing.
Measured
500-card library, driving
ImageCache.getImagethrough the same entry pointCardPaneluses,on the EDT:
Everything after the first render: 17,890ms → 4,959ms. Heap on the same measurement:
375–423MB before, 433–458MB after — about +40MB.
What this does not do
The first open is unchanged; that is the card faces being rendered for the first time, and it
is a separate problem. Caching the rendered face fixes the "new size" row (4946 → 1673) but
holds one full 488x680 render per card — about +550MB of heap on this measurement — so it
needs a bounded design before it is worth proposing. Panel-bookkeeping and async-load changes
I could not show a benefit for are parked until I can.
The measurement uses an install with no downloaded card images, so every card takes the
placeholder path — the worst case. With images present the absolute numbers will be smaller;
the capacity argument is unchanged.
No test: this is a timing and memory property of a cache, and a timing assertion in CI would
be flaky.
🤖 Implemented with the assistance of Claude Code (Opus 5).