[PD] GUI speed

Mathieu Bouchard matju at artengine.ca
Sun Oct 3 18:49:39 CEST 2010

On Tue, 28 Sep 2010, András Murányi wrote:

> Much of the speed improvement that can be made, can only be made by 
> modifying Tk's source code itself (or switching to a different 
> renderer).

I spoke a bit too fast. It depends on the situation. Still it's easy to 
make the GUI spend 75 ms on a single draw, it's just that there's 
something else sucking 1000 ms at the same time. There are some other 
situations where it's the opposite. But this is made by measuring times 
directly in the idle-function of tk/src/generic/tkCanvas.c and adding a 
XSync so that I get the time of a ping to the X server included in the 
figures (make sure the X11 commands are sent and applied, not just 
buffered in the tk process).

> ...and/or, as far as i understood, reinventing pd in a way that the GUI 
> doesn't chat with the core about gui elements and their properties, but 
> the core is limited to audio and other "abstract" calculations and it's 
> the GUI which takes care of everything that happens on the GUI.

I made something close to this already... but it's not automatically 

> but i have a feeling that Tcl/Tk is not that slow by itself but the 
> bottleneck is GUI<->core communication. C'mon, drawing a number with a 
> big font threatens the CPU? On the computers we have, in 2010? I can't 
> believe that.

Then why would you believe that the TCP/IP loopback that is used to 
communicate between Pd server and client would be any slower than a 
gigabit ethernet ?... On the computers we have, in 2010 ? It's not like 
it's going over a RS232 serial pork.

So, the answer is trickier than that. There are several other parts 
standing between a gui object and the X11 server. Here's the complete 
chain :

   1. GUI Object
   2. sys_vgui commands and the output buffer
   3. the TCP socket pair in loopback mode
   4. the input buffer
   5. [info complete] or equivalent
   6. [eval] or equivalent
   7. Tk Canvas commands
   8. Tk Canvas renderer
   9. Xlib and its output buffer
  10. the unix socket pair
  11. X server

Now, which ones of the above takes so much time, and how do you measure 
that ? Using only [cputime] will only give you the time of steps 1, 2, and 
part of 3. Using measurements in t_tkcmd.c (42) or pd_connect.tcl (43) 
will only give you info about 4, 5, 6, 7, and part of 3. The measurement I 
make from tkCanvas.c only gives me info about 8, 9, 10 and 11.

We need more measurements.

| Mathieu Bouchard ------------------------------ Villeray, Montréal, QC

More information about the Pd-list mailing list