[dev] [st] Slow rendering of bitmap fonts

From: Nikolay Belikov <nb_AT_nbelikov.com>
Date: Mon, 27 Jan 2020 21:46:50 +0300

Hello!

I would like to ask for help in finding the cause and fixing slow
rendering of PCF fonts. I noticed that scrolling in vim became laggy in
maximized windows when I configured st to use my favorite 6x13 bitmap
font. To reproduce, I compiled st from git repository without any
modifications and tried dumping large amounts of text to terminal.

    $ git describe --tags
    0.8.2-26-g895e5b5
    $ ./st -f "Fixed:pixelsize=13:style=SemiCondensed:lang=ru"
    $ stty size
    64 191
    $ time dd if=/dev/urandom bs=4k count=512 | base64 -
    (output clipped)
    real 0m46.223s
    user 0m0.048s
    sys 0m0.156s

Compare this to the timing when st is configured with whatever TTF font
Fontconfig offers for monospace, size being adjusted to match number of
rows and columns. This is about 27 times faster than PCF rendering,
despite that the latter does no rasterization and antialiasing, while
the former does.

    $ ./st -f "monospace:pixelsize=10"
    $ stty size
    64 191
    $ time dd if=/dev/urandom bs=4k count=512 | base64 -
    (output clipped)
    real 0m1.678s
    user 0m0.036s
    sys 0m0.119s

To find if this behavior is specific to st or is a problem in Xft or
elsewhere, I repeated the measurements with urxvt. There Xft renders
PCF font slower than TTF font, but not nearly as bad as it is for st.

    $ urxvt -fn "xft:Fixed:pixelsize=13:style=SemiCondensed:lang=ru"
    $ stty size
    64 189
    $ time dd if=/dev/urandom bs=4k count=512 | base64 -
    (output clipped)
    real 0m1.659s
    user 0m0.039s
    sys 0m0.229s

    $ urxvt -fn "xft:monospace:pixelsize=10"
    $ stty size
    64 189
    $ time dd if=/dev/urandom bs=4k count=512 | base64 -
    (output clipped)
    real 0m0.919s
    user 0m0.054s
    sys 0m0.115s

XLFD rendering is still faster, incidentally.

    $ urxvt -fn "6x13"
    $ stty size
    64 189
    $ time dd if=/dev/urandom bs=4k count=512 | base64 -
    (output clipped)
    real 0m0.466s
    user 0m0.025s
    sys 0m0.193s

A bit of diagnostic info. Please let me know what else I can provide.

    $ fc-match "Fixed:pixelsize=13:style=SemiCondensed:lang=ru"
    6x13.pcf.gz: "Fixed" "SemiCondensed"
    $ fc-match "monospace:pixelsize=10"
    DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
    $ pkg-config --modversion xft
    2.3.3
    $ pkg-config --modversion fontconfig
    2.13.1
    $ pkg-config --modversion freetype2
    23.1.17
    $ pkg-config --modversion x11
    1.6.9

I ran callrgind with both fonts, and attach collected data. However, I
don't see any obvious bottlenecks there.

-NB

Received on Mon Jan 27 2020 - 19:46:50 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 27 2020 - 22:12:14 CET