Repository navigation
Description
Summary
On native Linux, every ability tooltip hover freezes the game for 180–750 ms (often 2–3 consecutive long frames). The main thread spends almost all of that time inside libthai/libdatrie re-loading the Thai word-break dictionary /usr/share/libthai/thbrk.tri (579 KB), apparently many times per tooltip, instead of creating the breaker once and reusing it.
Pointing libthai at a tiny dictionary removes the freezes completely, which confirms the cause.
System
- Dota 2 build 26825343, native Linux, Vulkan
- Steam Linux Runtime 3 (sniper) 3.0.20261021.266025
- CachyOS (Arch-based), kernel 7.3, KDE Plasma (Wayland)
- NVIDIA RTX 4060, driver 620.73.04 · Intel i5-10400F · 32 GB RAM
- Game language English (
LANG=en_US.UTF-8, Steam setsLC_ALL=C)
Steps to reproduce
- Launch Dota 2 with
-condebug. - Enter Demo Hero with any hero.
- Hover any ability icon so the tooltip appears; repeat a few times.
Every hover (not only the first) produces lines like this in console.log:
02:44:38 Excessive frame time of 389.73ms clamped. Acting as if the frame only took 100.00ms
02:44:39 Excessive frame time of 509.31ms clamped. Acting as if the frame only took 100.00ms
02:44:39 Excessive frame time of 480.55ms clamped. Acting as if the frame only took 100.00ms
02:44:40 Excessive frame time of 502.01ms clamped. Acting as if the frame only took 100.00ms
Evidence
Main-thread profile (perf record -e cpu-clock:u -t <main tid>), samples only from the hitch window:
| DSO | share |
|---|---|
libc.so.6 (fread, malloc internals, _IO_sgetn, memcpy) |
81.4 % |
| libdatrie.so.1.4.0 | 7.7 % |
| libclient.so / libpanorama.so / everything else | < 2 % each |
During normal play the same thread is dominated by libclient, libpanorama and libscenesystem, and libc is about 4 %.
Main-thread I/O (/proc/<pid>/task/<tid>/io, 200 ms buckets):
- Hitch: about 6,400
readsyscalls and about 25 MBrcharper 200 ms, which is about 125 MB/s of 4 KBfreads at 100 % user CPU. - Idle: about 140 syscalls and under 1 KB per 200 ms.
25 MB per 200 ms is about 40 full reads of the 579 KB thbrk.tri in a fraction of a second, so the dictionary is clearly being reloaded per text run or layout rather than cached.
Workaround (confirmed)
Build a tiny valid dictionary and point libthai at it with LIBTHAI_DICTDIR. Pointing it at a missing directory does not work, because libthai then falls back to the default /usr/share/libthai/thbrk.tri.
mkdir -p ~/.local/share/dota-libthai && cd ~/.local/share/dota-libthai
printf '[0x002d,0x002e]\n[0x0e01,0x0e3a]\n[0x0e40,0x0e4e]\n' > thbrk.abm
printf 'การ\nและ\nที่\nเป็น\nใน\n' > words.txt
trietool thbrk add-list -e UTF-8 words.txt # trietool is in libdatrie; this produces a ~700-byte thbrk.triLaunch options (replace the path with your home directory):
LIBTHAI_DICTDIR=/home/<user>/.local/share/dota-libthai %command%
After this, 23 tooltip hovers in a row produced no hitches. The only side effect is worse Thai line breaking in chat.
Things ruled out
- GPU and driver: about 34 % GPU load, no Xid errors.
- Shader cache: overriding
__GL_SHADER_DISK_CACHE_READ_ONLY_APP_NAMEto drop the 405 MB merged cache had no effect. - Fonts: removing noto-fonts-cjk had no effect, and no system font files are mapped by the process.
Suggested fix
Create the libthai ThBrk object once (or use the shared default from th_brk_new(NULL) once) and reuse it. Do not call th_brk_new() / th_brk_delete() per text layout, and do not use an API path that reloads the trie each time.
Activity