Tk Source Code

View Ticket
Login
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: