Skip to content

Read cached thumbnails independently of generation - #120

Closed
k-kostin wants to merge 5 commits into
omacom:mainfrom
k-kostin:codex/thumbnail-cache-lane
Closed

k-kostin wants to merge 5 commits into
omacom:mainfrom
k-kostin:codex/thumbnail-cache-lane

Conversation

@k-kostin

@k-kostin k-kostin commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Rebased independently onto f73d8e4 after #216–218, retaining the earlier changes by @dhh. Read ready desktop-cache PNGs in a separate bounded two-worker pool, so occupied generators cannot hold them up. Misses go to the unchanged generation pool.

request → cache reader → fresh PNG: finish
                       → miss: existing generation queue

Normal tiles keep their requested bucket; #218's cached/ previews keep any-bucket lookup and priority. Sharp/text requests keep their existing generation routes. The same exception boundary protects both stages, and readers drain before generators. No GUI-thread disk I/O, new format, dependency or RAM cache. #218's early result delivery before cache writes remains intact. This targets main independently of #117.

Evidence

  • Real-QML regression: fill every generator, then request an existing tile or cached preview. Main: both wait until helpers are released. Candidate: both reach Image.Ready while helpers remain held, with the correct geometry. Covers cancelled queued misses, stale/corrupt/missing PNGs, removed sources, cache recursion and incomplete reserved IDs.
  • Eight alternating pairs on the new base, Qt 6.12.0/offscreen software rendering, warm OS page cache: with generators gated for 500 ms, tile Ready 508.13 → 0.71 ms, cached preview 506.00 → 0.73 ms (medians). These are QML readiness times, not physical frame presentation.
  • Idle eight-image cache burst: first Ready 0.85 → 0.79 ms, all Ready 1.31 → 2.33 ms. Eight synthetic 12 MP JPEGs with cold thumbnail cache: all Ready 207.31 → 207.96 ms. The two-reader bound has a small burst-completion cost; cold generation is essentially unchanged in this sample.
  • A local link-time fault injection throws at one cache-image decode: QML reports Error, then another image reaches Ready in the same engine. No test hook/plugin was added to Folio.
  • Final clean-head Release full suite: 283 passed, 0 failed, 1 existing root-trash skip; focused checks 9 passed. Pure-main controls fail both gate rows and the malformed-preview helper marker. Two fresh Astra reviews, identified edges fixed and final delta approved; diff check passes.

Merge Danger

Door: two-way; no cache migration.

Blast Radius: thumbnail scheduling.

Two bounded cache workers may themselves wait on slow cache/source I/O. Generator concurrency stays unchanged. #117 is independently based on main; once either PR lands, the remaining provider changes need their normal rebase and checks.

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Reads ready thumbnails in a separate two-worker pool so busy generators cannot hold them up.

  • Ready thumbnail images can load while generators are busy.

Static review found no actionable issues. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Request[Thumbnail request] --> Kind{Request kind}
  Kind -->|Normal tile| Readers[Two cache readers]
  Kind -->|Cached preview| Preview[Cache readers: priority 2]
  Kind -->|Sharp image or text page| Generators[Existing generation pool]
  Readers --> Hit{Fresh cached image?}
  Hit -->|Yes| Finish[Finish response]
  Hit -->|No| Generators
  Preview --> Finish
  Generators --> Finish
Loading

Reviews (3) · Last reviewed commit: "Use a literal helper invocation marker i..." · Reviewed by Greptile

@omarchybot omarchybot added the enhancement New feature or request label Nov 15, 2026
@dhh
dhh force-pushed the codex/thumbnail-cache-lane branch from d1b2c8f to 265e923 Compare November 18, 2026 14:39
@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks, Kirill. I've rebased this onto main and pushed it to your branch. Two things on main needed fitting in. First, the response's run() is now wrapped in a try/catch so a throwing decoder can't take Folio down (#173). That stays as it was: work() ends in your complete(), and it's marked as told first. Second, the details' new sharp/ requests (#155) have their own cache and id layout, so they now go straight to the generation pool, the same as page/, rather than through cached(), which would misread their ids. thumbnailsCachedImagesDoNotWaitForGenerators still fails when everything goes through one pool and passes with the cache lane. The whole suite passes locally (234 tests).

@k-kostin
k-kostin force-pushed the codex/thumbnail-cache-lane branch from 265e923 to 34b1363 Compare November 23, 2026 15:00
@dhh

dhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Superseded by #219 (shipped in v0.7.3), which serves disk-cached thumbnails and previews on a dedicated 2-thread cache pool independently of generation.

@dhh dhh closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants