Linux xterm startup extremely slow under certain locales (chinese zh_CN.UTF-8)
I noticed xterm/uxterm being extremly slow on startup and also on displaying the fonts menu when running under a zh_CN.UTF-8 locale. strace shows the culprit:
03.833720 writev(3, [{"1\1\4\0\1\0\7\0", 8}, {"*-GBK-0", 7}, {"\0", 1}], 3) = 16 <0.000032>
03.845074 writev(3, [{"1\1\5\0\1\0\t\0", 8}, {"*-*-GBK-0", 9}, {"\0\0\0", 3}], 3) = 20 <0.000044>
03.906162 writev(3, [{"1\1\5\0\1\0\v\0", 8}, {"*-*-*-GBK-0", 11}, {"\0", 1}], 3) = 20 <0.000046>
04.135018 writev(3, [{"1\1\6\0\1\0\r\0", 8}, {"*-*-*-*-GBK-0", 13}, {"\0\0\0", 3}], 3) = 24 <0.000040>
04.767843 writev(3, [{"1\1\6\0\1\0\17\0", 8}, {"*-*-*-*-*-GBK-0", 15}, {"\0", 1}], 3) = 24 <0.000031>
06.062369 writev(3, [{"1\1\7\0\1\0\21\0", 8}, {"*-*-*-*-*-*-GBK-0", 17}, {"\0\0\0", 3}], 3) = 28 <0.000032>
07.999531 writev(3, [{"1\1\7\0\1\0\23\0", 8}, {"*-*-*-*-*-*-*-GBK-0", 19}, {"\0", 1}], 3) = 28 <0.000032>
10.235677 writev(3, [{"1\1\10\0\1\0\25\0", 8}, {"*-*-*-*-*-*-*-*-GBK-0", 21}, {"\0\0\0", 3}], 3) = 32 <0.000032>
… and so on.
One possible workaround is to disable the GBK fontset in /usr/share/X11/locale/zh_CN.UTF-8/XLC_LOCALE
. This file has an entry like the following:
# fs3 class (Chinese Han Character GBK)
fs3 {
charset {
name GBK-0:GLGR
}
font {
primary GBK-0:GLGR
substitute GB13000.1993-1:GLGR
}
}
If you remove it, xterm will be back to its blazing fast startup time.
Further readings: Solaris Bugreport and fix in Solaris Chinese blog post related to this problem on FreeBSD Another blog post with the same solution as explained here And a chinese forum thread about the issue
Proper fix welcome…