Tk Source Code

View Ticket
Login
2026-10-16
10:01 • Closed ticket [290ce5f4]: TK performance on X11 with Forwarding (via SSH) decreased when upgrading from 8.6.10 to 8.6.11 plus 7 other changes artifact: 4c99189b user: jan.nijtmans
10:00
Fix [290ce5]: Tk performance regression on X11 check-in: 9ed4e92e user: jan.nijtmans tags: core-8-6-branch
2026-10-15
15:12
Fix [290ce5]: Tk performance regression on X11 check-in: 33ef282a user: jan.nijtmans tags: core-9-0-branch
15:09
Fix [290ce5]: Tk performance regression on X11 check-in: 3d1d80d0 user: jan.nijtmans tags: trunk, main
2026-10-02
15:41 • Ticket [290ce5f4] TK performance on X11 with Forwarding (via SSH) decreased when upgrading from 8.6.10 to 8.6.11 status still Open with 3 other changes artifact: 799e25fe user: serhiy.storchaka
14:55
Fix [290ce5f460]: Tk performance on X11 with forwarding decreased in 8.6.11.

Since [7f20966df9], text measurement with Xft is wrapped in an X error handler, and every tenth deletion of an error handler did a round trip with the X server (XSync) to catch errors for the outstanding requests. Skip it if no request was sent while the handler was active, so that no error can come for it. This removes most round trips when creating many widgets with text, e.g. 1200 -> 260 for a grid of 400 ttk::buttons without bidi. closed check-in: 2b118379 user: serhiy.storchaka tags: x11-error-handler-sync

2022-08-01
19:31 • Ticket [290ce5f4] TK performance on X11 with Forwarding (via SSH) decreased when upgrading from 8.6.10 to 8.6.11 status still Open with 4 other changes artifact: 05530f73 user: anonymous
2022-07-28
21:51 • Ticket [290ce5f4]: 3 changes artifact: 629818ef user: jan.nijtmans
18:35 • Add attachment tk-8.6.11.profile to ticket [290ce5f4] artifact: ce06d6da user: anonymous
18:34 • Add attachment tk-8.6.10.profile to ticket [290ce5f4] artifact: 4664e43f user: anonymous
18:32 • Add attachment erictest.py to ticket [290ce5f4] artifact: 27503ce7 user: anonymous
18:31 • New ticket [290ce5f4] TK performance on X11 with Forwarding (via SSH) decreased when upgrading from 8.6.10 to 8.6.11. artifact: 02e1c1bd user: anonymous

Ticket UUID: 290ce5f460eb45282b7fa4aa8d7b821c2f87875
Title: TK performance on X11 with Forwarding (via SSH) decreased when upgrading from 8.6.10 to 8.6.11
Type: Bug Version: 8.6.11
Submitter: anonymous Created on: 2022-07-28 18:31:54
Subsystem: (unused) Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-16 10:01:17
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-10-16 10:01:17
Description:
On Linux (openSUSE Leap 15.3 x86_64 with X11), when upgrading from TK 8.6.10 to 8.6.11, the time it takes to draw widgets, when using X11 Forwarding over SSH, increased by 44% (3.161 seconds versus 4.564 seconds).  Using python3.6.15 TK libraries, the following test code is used to demonstrate the issue:

#!/usr/bin/python3

from tkinter import Tk, N, S, W, E, ttk
#import time
#start = time.time()

root = Tk()

for i in range(20):
    for j in range(20):
        disp = str(i*20+j)
        ttk.Button(root, name=disp, text=disp).grid(row=i, column=j, sticky=N + S + W + E)

#root.mainloop()
#root.update_idletasks()
root.update()
#end = time.time()
#print(end - start)


Running this over SSH (with X Forwarding) from a host that has ping latency of 2.5ms (from where the X server is running) results in slow rendering.  When run on a host that is closer (lower latency such as 0.3ms) results in immediate rendering.  Something between these versions caused TK to become more latency sensitive.  

I ran the above code through the Python Cprofile and can upload the output.
User Comments: jan.nijtmans added on 2026-10-16 10:01:17:

Fixed in [3d1d80d012551093|trunk], core-9-0-branch and core-8-6-branch

Many thanks!


serhiy.storchaka added on 2026-10-02 15:41:03:

The slowdown comes from [7f20966df9] (in 8.6.11), not from [b101d48433]: text measurement with Xft is now wrapped in an X error handler, and every tenth deletion of an error handler does a round trip with the X server to catch errors for the outstanding requests. For the example in the report it adds about 4 times more round trips in a build without bidi.

Proposed fix in branch x11-error-handler-sync: skip the round trip if no request was sent while the handler was active.


anonymous (claiming to be ericj) added on 2022-08-01 19:31:59:
I checked the source that I am compiling from and I don't see the patch you mention applied.  The build I started having issues with is revision number 47 (from January 19, 2021) @ https://build.opensuse.org/package/revisions/openSUSE:Factory/tk

jan.nijtmans added on 2022-07-28 21:51:34:

Could it be that [b101d484339a3a01|this] commit is causing the slowdown? If so, it's really up to the Xft library to do proper locking.

See: [8ebed330ed]


Attachments: