[Y-devel] Threading adventures
Erik erikhill at hawaii.rr.com
Tue Mar 9 07:35:14 GMT 2004
Well, I've been thinking about threading Y for a while and researching the
code and process.
Originally, I decided that it would be a good idea to thread Y, because I
suspected that it would result in gains in three areas: Latency, avoiding
priority inversion, and making better use of SMP. That was the order of
importance that I put them. However, after looking at the design and code
more carefully, the only possible benefit I could get would be threading the
viewport update, currently the most work-intensive part of Y. At first I
believed that this would result in all sorts of locking problems, but now I
suspect this isn't true -- each "rectangle" update in a viewport update
sequence is fairly independant, at least in terms of "writing", modifications
to buffers between two rectange regions don't overlap (the regions defined by
two separate "iterations" of rectangle update don't interfere/overlap with
any other iterations), which means I might not even have to lock buffers at
all. Then again, the benefits are nearly nil -- the first two -- latency and
priority inversion -- only make sense if Y windows were more like X windows
in design -- which it isn't. If my understanding is correct, the process of
updating the viewports -- tied intimately with the refresh event in the
display hardware -- doesn't ever happen more often than it absolutely needs
to (although it can happen less often). Therefore, latency isn't a problem
in cases where the widget rendering code is very fast -- it's possible that
widget changes will be rendered faster than the video hardware can update.
And multiiple changes don't interfere with each other, they just build up
dirty rectangle lists -- to be dealt with in one blow by the next viewport
update sequence. There are still cases where you might get a
network-priority inversion -- but this won't be fixed by threading. Keeping
latency low is best dealt with by keeping Y's workload atomic with fast
atoms. In other words, no special events which are very CPU intensive in a
single call.
So I'm giving up on threading, partially because all but the viewport update
would be intensily involved, and partially because the payoff is so low.
Looking for other places to be of use.
Erik
More information about the Y-devel mailing list
2026 © www.Y-Windows.Org - All Rights Reserved