You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No in-flight dedup on the chunk path: concurrent reads of the same chunk fetch and decode twice #7
The cache is read while the task list is being built and written only after the worker returns. Two concurrent getWorker calls covering the same chunk both observe a miss, so both fetch the bytes and both run a codec decode.
Where
src/get-worker.ts:
:760 — const cachedChunk = cache.get(cacheKey), during task-list construction.
:798, :839, :856 — the corresponding cache.set calls, inside the task, after the decode completes.
Nothing occupies the key in between.
Why it matters
Overlapping viewport reads are the normal case for a tiled image viewer: a pan issues a new read while the previous one is still settling, and adjacent requests routinely share chunks. The duplicated work is a wasted network round-trip plus a wasted worker decode — the expensive half — and it is worst exactly when the pool is already saturated.
Suggested fix
Key pending promises, not just settled chunks: on a miss, insert the in-flight promise under the cache key so a concurrent caller awaits it instead of starting its own task. Worth pairing with cleanup on rejection — a cached rejected promise would otherwise poison that key permanently (we have the same bug in our own parquet cache, so this is a sympathetic report rather than a criticism).
Activity
thewtex commentedon Aug 10, 2026
Closing per #10