fzf
fzf copied to clipboard
[Feature request] improve performance handling iterm2 image protocol in `--preview`
Checklist
- [X] I have read through the manual page (
man fzf) - [X] I have searched through the existing issues
- [x] For bug reports, I have checked if the bug is reproducible in the latest version of fzf
Output of fzf --version
0.55.0 (v0.55.0)
OS
- [X] Linux
- [ ] macOS
- [ ] Windows
- [ ] Etc.
Shell
- [X] bash
- [ ] zsh
- [X] fish
Problem / Steps to reproduce
I noticed that fzf preview takes quite a long time when showing big images with iterm protocol. This gets annoying when browsing filesystem. My measurements has shown that without fzf rendering takes around 25ms and with fzf it gets up to 400ms.
measurement with fzf
# to make sure chafa is not the issue
chafa -f iterm --view-size 91x44 a.png > a.chafa
# fzf preview loads ~400ms
echo foo bar | fzf --preview '/bin/cat a.chafa'
https://github.com/user-attachments/assets/0897dc27-7348-4e82-ae46-7e5cb13806a6
fzf opened at 11th frame 0.7333s till preview rendered at 18th frame 1.20s -> 0.4666s
baseline measurement
❯ hyperfine '/bin/cat a.chafa' --show-output
...
Time (mean ± σ): 25.2 ms ± 1.0 ms [User: 0.4 ms, System: 10.0 ms]
Range (min … max): 22.5 ms … 27.9 ms 129 runs
image used
Since without fzf the rendering takes much less time, it seems like fzf has quite a lot of overhead somewhere. It would be great to optimize it