-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queue disk cache writes separately #150
Comments
Thought about this a bit more and instead of queueing cache writes separately, I've instead started delivering results before caching them. Doing so avoids the need to write a separate queue, add an additional thread, or use any more memory. However, we still get most of the benefits of a separate queue, in that if you load a small number of images, they're shown to the user more quickly. Calling this fixed here: 8cd520e |
Two things (I didn't dig too deep into the impl):
At glance LockedRequest does just this, but I'd like to confirm. |
|
Currently requests wait until their contents are written to the cache before returning a result. Although this is safe and simple, writes to the disk cache can take a long time. To avoid this delay we can allow requests to queue writes to the disk cache.
To avoid spikes in memory usage, this queue would have to be blocking and size bounded. For apps loading lots of small photos, this wouldn't be much of a win because requests would constantly be blocked on the queue. However, for apps that load the occasional large image, we can substantially decrease overall request times.
Implementing this requires one of two changes:
1 would be relatively easy to implement by adding an additional optional ResourceCopier interface and falling back to blocking writes for un-copyable resources.
2 would be more resource efficient, but would push some amount of complexity into Transcoders and generally be more complex to implement.
The text was updated successfully, but these errors were encountered: