Render image previews lazily #75

Open
opened 2025-10-14 15:38:32 -06:00 by navan · 0 comments
Owner

Originally created by @VAWVAW on 6/17/2025

Profiling the startup of iamb in foot using flamegraph, I noticed that most of the cpu time was spent rendering image previews. This PR changes the rendering to be in the background (not blocking ui responsiveness) and lazily (on message rendering).

I had some bugs if the last message is an image:

  • Scrolling with ^E and ^Y doesn't work if the last message is focused
  • if only one image is loaded and the rest of the loaded events are reactions, older events don't load

Profiling data

before optimizations:
flamegraph-original
with lazily computed sixel preview:
flamegraph-lazy-sixel
and lazily decoded jpg:
flamegraph-lazy-jpg

*Originally created by @VAWVAW on 6/17/2025* Profiling the startup of iamb in `foot` using `flamegraph`, I noticed that most of the cpu time was spent rendering image previews. This PR changes the rendering to be in the background (not blocking ui responsiveness) and lazily (on message rendering). I had some bugs if the last message is an image: - Scrolling with ^E and ^Y doesn't work if the last message is focused - if only one image is loaded and the rest of the loaded events are reactions, older events don't load # Profiling data before optimizations: ![flamegraph-original](https://github.com/user-attachments/assets/6aa5995c-5092-44ec-b5f7-522b200b6b6c) with lazily computed sixel preview: ![flamegraph-lazy-sixel](https://github.com/user-attachments/assets/38be338c-b4d1-44c0-b1cf-2edc5d32e630) and lazily decoded jpg: ![flamegraph-lazy-jpg](https://github.com/user-attachments/assets/781d14cb-f1c4-40a1-b6cf-96afd0e58a72)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github/iamb#75
No description provided.