cog1to / st-ligatures

Patches for ST (suckless terminal) that add support for ligatures drawing
54 stars 5 forks source link

Stuttering while scrolling in (neo)vim #21

Closed sammynilla closed 1 year ago

sammynilla commented 1 year ago

Hello there!

I'm not sure if this has been experienced by others who use this patch along with the suckless terminal, but I've tried applying the current ligatures patch on my current build of st, as well as on a fresh pulled copy of st and have noticed the same results. For whatever reason I tend to notice a fairly distinct stutter (lag?) while scrolling (j/k) in both Vim and Neovim while having this patch applied vs when not.

For reference, my file isn't very big. Only about 300LoC or so. I don't think I can say the issue is the font (Jetbrains Mono) either as I've tested it under both Kitty and Alacritty without the same effect being present. I've tested both editors with no zero configuration as well.

I'm not really sure in which direction I should go about getting past this issue, but for the moment I've decided to resort to having no ligature support as it's not an incredibly important thing for me but more-so a nicety. However, if you, or anyone else using this patch has any suggestions then I'd be more than happy to try some things out in order to get through this issue of mine.

Thank you for your time.

cog1to commented 1 year ago

Hello. Current implementation works kind of like a post-processing effect. Essentially it adds an additional screen pass for each screen update, so it is expected to be not very fast.

Thanks for the report, though. I'll see if there's anything I can improve in terms of performance. I wasn't focusing on it since it was working fine on my build and no one was complaining about it before.

cog1to commented 1 year ago

Hello. I did some refactoring, and upgraded to st 0.9. If you have time, check out patches in the update-0.9 branch. Can't guarantee any groundbreaking improvements, but it should be slightly more efficient.

If you find any other issues, don't hesitate to report back. It's a fairly big rewrite, so I could've messed something up.

sammynilla commented 1 year ago

The update-0.9 branch seems to function better than I remember the previous patches performing. I went ahead and recorded a video from my end in case you wanted to just see the, now, very slight difference in scroll performance. Arguably it's even less noticeable when block scrolling instead of line-by-line.

Just for note on the video above, the st on dwm tag 3 contains no ligatures, while the st on tag 1 is using the most recent ligatures patch from your new branch.

cog1to commented 1 year ago

Okay, thanks. I slightly updated the patch, but the changes are kind of cosmetic and should not affect performance further.

I think I squeezed what I could out of the current logic. You could also try to compile with -O2 instead of the default -O1, but if the limiting factor now is the glyph shaping logic itself, it probably won't help much.

UPD: I'll try one more thing later this week, maybe it'll improve stuff.

cog1to commented 1 year ago

Updated to a new version with some more improvements, give it a try.

Don't get your hopes high though. From what I gathered, the problem might now be not with the algorithm itself, but with individual spikes on particularly fragmented lines, so this might not eliminate all of the stuttering, just some of it.