Repository navigation
Conversation
kean
force-pushed
the
fix/cache-limits-keys-contains
branch
from
September 26, 2026 20:40
1c54341 to
bd01459
Compare
kean
force-pushed
the
fix/cache-limits-keys-contains
branch
3 times, most recently
from
November 1, 2026 15:14
66c00a2 to
c1ce796
Compare
Each setter went through Cache.conf's separate get and set, so two threads writing different limits could put back each other's old value.
Concurrent requests for one URL with different imageIDs shared a TaskLoadImage, which stored the image under the first request's keys only. The data is still fetched once, by URL.
Both queried the data cache directly, without the read guard that cachedData(for:) has, so they said yes for a request the pipeline would never read from disk for.
… disk The image was encoded before the data cache and .disableDiskCacheWrites were checked, so with no data cache (the default) every call paid a synchronous encode and threw the result away.
kean
force-pushed
the
fix/cache-limits-keys-contains
branch
from
November 3, 2026 00:51
c1ce796 to
d861edd
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four small caching fixes from the DefectRepros batch:
ImageCachelimits could overwrite each other: each setter went throughCache.conf's separategetandset, so acountLimitwrite on one thread could put back the oldcostLimitwritten on another. The limits are now updated under the lock withupdateConf;value(forKey:)is untouched.imageIDs were coalesced into oneTaskLoadImage, which stored the image only under the first request's keys, so the second ID missed the memory cache and downloaded again. The customimageIDis now part ofTaskLoadImageKey(nilfor default requests, so the common path hashes nothing extra); the data is still fetched once, by URL. This also fixesImagePrefetcherdeduplicating and stopping such requests under one key.containsCachedImage(caches: .disk)andcontainsData(for:)returnedtruefor a request with.disableDiskCacheReads(or.reloadIgnoringCachedData) whilecachedDataandcachedImagereturnednilfor it: they queried the data cache without the read guard the other methods have.storeCachedImageencoded the image before checking whether there is a data cache or whether the request allows disk writes, so with the default configuration (no data cache) every call paid a synchronous encode and threw the result away. The data cache and the write option are now checked first.