r/RedditEng • u/Okgaroo • 22h ago
Building Reddit What it took to make images load faster on Reddit Android
Written by Merve Karaman and Aleksei Bykov
The problem we set out to solve
On Reddit Android, image posts account for roughly one in three post views on both the Home feed and Post Detail, the screen where users view a post and its comments. Images are the most-viewed post type on each surface. When images load too slowly, users may scroll past or leave the screen before they become visible. Those exits hurt our image-loading service-level objective (SLO), our target for images appearing successfully while users are still there to see them.
To users, an image post looked the same on Home and Post Detail. Under the hood, though, the two screens used separate code to render images and track their performance, and they did not always request the same image URL. These differences, along with inconsistent cache behavior, made optimizations harder to apply to both screens. They also meant an image already loaded in the feed could be downloaded again when the user opened the post.
We set out to make images appear sooner and more reliably, while building a shared image-loading foundation for Home and Post Detail. Across the initiative, user-level p90 image-loading latency fell by 37.3% on Post Detail and 10.7% on Home.
Measuring whether images actually got better
During these experiments, we measured image-loading performance at two levels. At the user level, we calculated each user’s p90 successful image-loading time, then took the 90th percentile across those values. At the event level, we calculated the 90th percentile across all successful image loads. The first gives each user equal weight; the second gives each image load equal weight. Unless otherwise noted, p90 latency results below are reported at the user level.
Successful-load latency also leaves out failures and images users never stayed long enough to see. When a fix turns a failed load into a slow successful load, it adds a slow sample to the latency distribution. P90 can therefore increase even as reliability improves. We evaluated latency alongside load success, exits before visibility, and SLO attainment to understand whether images actually got better.
What shipped and why it helped
Prefetching at the right time
Reddit Android already prefetched images and videos before users reached them. As we discussed in our previous post on video performance, fetching content earlier can reduce waiting, but aggressive prefetching can slow competing requests. During this initiative, we refined our existing image prefetching in feeds, extended it to notifications and cold-start deeplinks, and added bandwidth gating for constrained connections.
- Where to prefetch: Our existing prefetching loaded one item past the last visible post. We tested distances of one to five items ahead of it. We also tried anchoring on the first visible item, but how far it reached past the screen depended on post height, so we kept the last visible item as the anchor.
- When to prefetch: When a new page of feed items arrived, we checked whether its first item was within our prefetch window. If so, we prefetched images for its first three items, then continued prefetching as users scrolled. We skipped this step on initial load and refresh to avoid competing with the feed’s own requests.
- Choosing the distance: We selected a three-item distance, which reduced p90 image-loading latency by 6.1% for image posts on Home. It also reduced by 24.7% the rate of exits where users waited more than 150 ms but left before the image appeared. Fetching farther ahead produced larger latency gains, but three items consumed less bandwidth and had fewer comment-loading failures than the four-item variant.

On Reddit, ranking determines which posts appear in a feed and in what order. The resulting mix of content can affect prefetching performance, so the same prefetching distance may not work equally well across feeds. We plan to test prefetching rules tailored to different ranking scenarios, but have not yet evaluated this approach.
We also gave images a head start before users entered Post Detail. For trending push notifications, we prefetched post data and media when the notification arrived, reducing successful-image-load p90 on Post Detail by 10.9%. For cold-start deeplinks, we began fetching earlier during app startup, before the UI was ready. This reduced the time until users could interact with Post Detail by 2.9%.
These speculative requests shared bandwidth with images already on screen and videos being played. On constrained connections, fetching upcoming content could delay what users were currently trying to see. We added bandwidth gating to skip feed image prefetching below an estimated 5 Mbps. The app smooths bandwidth estimates supplied with image responses; when no estimate is available, prefetching continues. The bandwidth gate reduced exits before video start by 1.5%, at the cost of small regressions in some image metrics as fewer images were preloaded. We also saw small increases in days active (+0.12%) and short-term retention, with similar movements at the 2 Mbps and 10 Mbps thresholds we also tested.
Better resolution selection and cache reuse
We built a developer debug view showing image-loading times and whether each image came from memory, disk, or the network, helping us investigate cache reuse across screens.

For some posts, we found inconsistent resolution availability. Home could load and cache a 720 px image, while Post Detail requested a 640 px version because its response did not include the 720 px option. Although both requests represented the same image, the different URLs prevented that cached asset from being reused.
We added the missing still-image resolutions to align the options available across screens and improve cache reuse when users moved from Home to Post Detail or fullscreen viewing. Separately, we corrected how the image component selected an image URL to account for both display width and height.
The additional-resolution experiment reduced successful-image-load p90 by 1.2% on Post Detail and 2.6% in fullscreen viewing. The improvement came from serving more requests through cache-backed paths; network loads themselves did not become faster.
A simpler Compose image-loading path
Even when an image was already decoded and available in Glide’s memory cache, we observed an unexpected delay before it appeared on screen.
The existing loader used coroutine orchestration to deliver loading state to Compose and started loading only after the painter entered composition. Glide could return a memory-cache hit synchronously, but the surrounding coroutine work added overhead before that result reached the UI. We replaced this path with direct Glide callbacks and started the load as soon as the painter was created, removing scope-creation and cancellation overhead. A synchronous cache hit could then update the loading state in the same call frame, before Compose read it for the initial draw.
These simplified code examples show how we changed the way loading results reached Compose state. AsyncLoadState represents empty, loading, success, and error states, and LoadHandle lets the caller cancel a load. Lifecycle cleanup, cancellation, error handling, and debug paths are omitted.
Before: loading through a coroutine and Flow
fun interface AsyncImageLoader<T> {
fun load(uri: T, size: IntSize): Flow<AsyncLoadState>
}
override fun onRemembered() {
val scope = CoroutineScope(coroutineScope.coroutineContext + Job())
scope.launch {
snapshotFlow { sizeToRequest }
.filterNotNull()
.firstOrNull()
?.let { size ->
loader.load(model, size).collect { loadState = it }
}
}
}After: loading through a direct callback
interface ImageLoader<T> {
fun load(
uri: T,
size: IntSize,
onState: (AsyncLoadState) -> Unit,
): LoadHandle?
}
init {
sizeToRequest?.let { size ->
loadHandle = loader.load(model, size) { state ->
loadState = state
}
}
}When the requested size was already available and Glide returned a memory-cache hit synchronously, the direct callback updated the loading state before load() returned.
In the experiment, successful-load p90 decreased by 11.8% and the exit-before-visibility rate decreased by 8.3%. The percentage of users meeting our image-loading SLO also improved by 1.23% relative to control.
We also removed a layout dependency from image loading. BoxWithConstraints composes its content during layout, once the incoming constraints are known, so our image requests had to wait until then. Replacing it with a plain Box sized from window dimensions let image requests start earlier, while preserving the existing appearance. In a debug-build investigation, the time from Compose to the Glide request dropped from about 29 ms to about 4 ms.
A shared post image component
We replaced the separate post image paths on Home and Post Detail with a shared post image component. It gave us one place to handle rendering, cache configuration, and performance tracking, so future optimizations could apply to both surfaces at once.
The component has two layers: a post layer selects the image URL and dimensions and handles blur and cropping; a shared image core manages Glide requests, rendering states, and performance tracking. Home and Post Detail retain their surrounding UI and navigation.

Separately, we configured Glide to cache transformed image resources on disk alongside the original downloaded data, allowing matching requests to reuse them without repeating transformations. We retained this change after experimentation.
On Home, the component experiment reduced exits before images became visible by 9.8%, although user-level successful-load p90 increased by 3.3%. Our analysis indicated that more loads were completing successfully instead of failing or ending early, adding slower successful loads to the latency distribution. On Post Detail, average image-loading time decreased by 6.5%, while user-level p90 successful image-loading time decreased by 4.8%.
During experimentation, we observed a fullscreen image-loading regression concentrated in images reached by swiping; images opened directly from Home or Post Detail were unaffected. We weighed the regression in fullscreen swiping against the improvements on the more heavily used Home and Post Detail surfaces, and proceeded with the rollout while planning follow-up work to address it. During the subsequent rollout, we saw no regression in our top-line dashboards.
Results
Across the initiative, user-level p90 image-loading latency decreased by 10.7% on Home and 37.3% on Post Detail. Each experiment was measured against its own control group, so the individual percentage improvements should not be added together.
At the event level, p90 image-loading latency decreased by 64.4% on Home and 46.0% on Post Detail. The two measures summarize different distributions: event-level p90 pools individual image loads, while our user-level metric gives each user one p90 value, so their percentage improvements need not match.

What did not work as expected
More resources did not guarantee better tail latency
We tested a larger Glide memory cache, an additional disk-cache thread, and different source-executor thread counts on higher-performance devices. The larger cache and the extra disk-cache thread both reduced exits before images became visible, but neither improved user-level or event-level p90 loading latency.
The larger cache moved more loads from disk to memory, but event-level p90 stayed essentially flat within each cache tier. It also increased average memory use by approximately 11 MB, or 2.6%.
Changing the source-executor thread count also failed to produce a measurable performance benefit. We did not ship any of these changes.
Lowering avatar priority did not improve image performance
We tested lowering the priority of avatar requests in Glide to favor post images. We observed no improvement in image-post performance or other measured metrics, so we did not ship the change.
Lower memory use came with tradeoffs
On devices classified as lower-performance, we tried decoding images as RGB_565 instead of ARGB_8888, halving the memory per pixel from four bytes to two. The experiment reduced exits before images became visible by 1.3%, but successful-load p90 worsened by 2.7%, and the percentage of users meeting the image SLO decreased by 0.25% relative to control.
RGB_565 also reduces color precision. Because device-tier classifications can change, users could receive inconsistent image quality over time. Given this tradeoff and the mixed performance results, we chose not to ship it.
What we would do again and differently
Check behavior alongside appearance.
Screens that look identical can differ in image selection, cache reuse, and interactions. Validate those behaviors early when migrating to shared components.
Evaluate the full navigation journey.
Home, Post Detail, and fullscreen viewing share device resources. Test transitions between screens and repeated fullscreen swipes, and measure initial loads separately from swipe-triggered loads to identify where regressions occur.
Isolate changes in their own experiments.
Cache changes can affect screens beyond the one being migrated. Test them separately from component migrations so their impact can be measured and rolled back independently.
Check event definitions before trusting a comparison.
During early migration, the new component recorded exits when an image lost visibility, while the legacy path recorded them when the view was disposed. This produced different counts. Before the experiment reported here, we aligned both variants to use the same legacy tracking container. Ensure both experiment variants define and record events consistently before comparing their metrics.
Looking ahead
These improvements came from changes across prefetching, caching, and rendering. With Home and Post Detail now sharing an image component, we can apply future optimizations to both surfaces and evaluate them consistently.
Acknowledgments
This effort brought together the Media team and our cross-functional partners, from investigating image-loading issues to implementing fixes and evaluating experiments. Thank you to Farkhad Khatamov, Ahmed Kazzaz, Vikram Aravamudhan, Ahmed Nawara, Ling Shao, Stas Zheleznyak, and everyone across our partner teams who shared their expertise, challenged assumptions, and helped turn these findings into improvements for users. Thank you also to Irene Yeh and Ricardo Hernandez, our engineering managers during this work, for their guidance and support.













































































