kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.12k stars 971 forks source link

Performance Issues with font with many ligatures e.g. JetBrains Mono #6236

Closed belafonte closed 1 year ago

belafonte commented 1 year ago

Describe the bug Performance drops with font with many ligatures and larger files ( e.g. JetBrains Mono Font ).

https://www.jetbrains.com/lp/mono/

To Reproduce Steps to reproduce the behavior:

Set JetBrains Mono in config.

Open larger text file.

Cursor is slow.

Environment details

kitty 0.26.5 created by Kovid Goyal
Darwin Jans-Laptop.fritz.box 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
ProductName:        macOS ProductVersion:       13.3.1 BuildVersion:        22E261
Frozen: True
Paths:
  kitty: /Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /bin/zsh
Loaded config files:
  /Users/dreieinsvier/.config/kitty/kitty.conf

Config options different from defaults:
active_tab_title_template {fmt.fg._fff}{title}
editor                    nvim
enable_audio_bell         False
enabled_layouts           ['splits']
font_family               JetBrains Mono SemiBold
font_size                 12.0
inactive_text_alpha       0.7
italic_font               JetBrains Mono SemiBold Italic
modify_font:
    cell_height 120%
scrollback_lines          4000
shell                     fish
tab_bar_style             powerline
tab_title_template        {fmt.fg.c2c2c2}{title}
window_border_width       (0, 'px')
Added shortcuts:
    cmd+d →  launch --location=hsplit --cwd=current
    cmd+left →  send_text all \x01
    cmd+right →  send_text all \x05
    opt+left →  send_text all \x1b\x62
    opt+right →  send_text all \x1b\x66
Changed shortcuts:
    cmd+1 →  goto_tab 1
    cmd+2 →  goto_tab 2
    cmd+3 →  goto_tab 3
    cmd+4 →  goto_tab 4
    cmd+5 →  goto_tab 5
    cmd+6 →  goto_tab 6
    cmd+7 →  goto_tab 7
    cmd+8 →  goto_tab 8
    cmd+9 →  goto_tab 9
    cmd+k →  combine : clear_terminal scrollback active : send_text normal,application \x0c
    shift+cmd+d →  launch --location=vsplit --cwd=current
Colors:
    active_border_color       #7287fd   
    active_tab_background     #8839ef   
    active_tab_foreground     #eff1f5   
    background                #eff1f5   
    bell_border_color         #df8e1d   
    color0                    #5c5f77   
    color1                    #d20f39   
    color10                   #40a02b   
    color11                   #df8e1d   
    color12                   #1e66f5   
    color13                   #ea76cb   
    color14                   #179299   
    color15                   #bcc0cc   
    color2                    #40a02b   
    color3                    #df8e1d   
    color4                    #1e66f5   
    color5                    #ea76cb   
    color6                    #179299   
    color7                    #acb0be   
    color8                    #6c6f85   
    color9                    #d20f39   
    cursor                    #dc8a78   
    cursor_text_color         #eff1f5   
    foreground                #4c4f69   
    inactive_border_color     #9ca0b0   
    inactive_tab_background   #9ca0b0   
    inactive_tab_foreground   #4c4f69   
    mark1_background          #7287fd   
    mark1_foreground          #eff1f5   
    mark2_background          #8839ef   
    mark2_foreground          #eff1f5   
    mark3_background          #209fb5   
    mark3_foreground          #eff1f5   
    selection_background      #dc8a78   
    selection_foreground      #eff1f5   
    tab_bar_background        #bcc0cc   
    url_color                 #dc8a78   

Important environment variables seen by the kitty process:
    PATH                                /Applications/kitty.app/Contents/MacOS:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/dreieinsvier/.cargo/bin:/Users/dreieinsvier/.local/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
    LANG                                en_US.UTF-8
    SHELL                               /bin/zsh
    USER                                dreieinsvier
kovidgoyal commented 1 year ago

Does not reproduce for me. Indeed, ligatures are rendered only once on first use, just like all glyphs in kitty, so the number of ligatures is irrelevant once they are rendered, they are rendered.

belafonte commented 1 year ago

It does not happen always and yes it might be related to my specific setup as it mostly occurs on long nvim sessions with many terminals.

But there is some issue and it is definitely related to ligatures, since turning off ligatures resolves the issues directly.

From what i observed, i seems that at some point there is some heavy processing on the CPU. When ligatures are enabled and i scroll in nvim, CPU spikes.

image

When turning of ligatures, everything is working smooth again. So yes it might also be a nvim but, but still it is weird, that turning ligatures resolves the issue.

kovidgoyal commented 1 year ago

Well if you can find a simple reproducer I can take a look.