Re: [dev] [st] Slow rendering of bitmap fonts

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Tue, 28 Jan 2020 00:07:05 +0100

On Mon, Jan 27, 2020 at 09:46:50PM +0300, Nikolay Belikov wrote:
> 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

Hi,

No issues here on my average laptop running OpenBSD:

    0m00.19s real 0m00.00s user 0m00.03s system

Also make sure to measure properly. For example: I would store the random data
to a location first and test using the same data. Then you're not measuring
also the randomness generation and base64 encoding etc.

The mail has many assumptions, maybe try validating if each assumption is true.

My random guess is fontconfig is probably doing something crazy.

-- 
Kind regards,
Hiltjo
Received on Tue Jan 28 2020 - 00:07:05 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 28 2020 - 00:12:13 CET