[sldev] UI & Multithreading performance
Dzonatas Sol
dzonatas at gmail.com
Thu May 14 18:11:46 PDT 2009
I wanted to share something a bit of a discovery about the UI and
multithreading that may interest those that keep performance in mind.
First, an image of omvviewer (slviewer on linux) 1.22.11 with the system
monitor run. You'll notice at (time interval):
T-250: I started omvviewer. Multiple threads fired and begin work.
T-200: It starts to calm after startup. I switch window focus to System
Monitor. It idles.
T-150: I switch focus back to omvviewer window. It begins the thrash one
processor only while other processors idle. 100% single processor usage.
T-125: I switch focus back to System Monitor. Omvviewer begins to idle
again, notice there is mainly one processor active (above 20% util) at a
time.
T-50 : Very apparent how only one processor is active at a time.
http://mono.dzonux.net/file/omvviewer-20090514.png
Second image, this next one is of MonoVida Studio, which uses omvviewer
as a backend and C#/Gtk#/Glade# for its front-end. All UI events (keys,
motions, etc) are through Gtk. There is no SDL being used.
Between T-250 and T-0, I switch often between the chat window "Local
Chat" and the main view as I conversate and finally the System Monitor
to get a snapshot.
Notice that there are mainly two processors that are active at a time.
Notice also that there is no 100% usage of a single process like in the
previous session at T-150.
In fact, the idle nanosleep()/timeout (in the render loop) has been
completely disabled since Gtk sends events as they happen instead of the
need to poll like in SDL.
http://mono.dzonux.net/file/monovida-20090514.png
Conclusion,
Even when GTK events are still being handled within the main loop of the
viewer, GTK appears to detect multiprocessors and multithread as it can.
This alone was enough that under normal viewer usage (like a meeting) it
never hit 100% processor utilization with GTK. I think this conclusion
is more than fair since you'll notice in the first picture that the
immediate scene to render is mostly blank in comparison to a scene with
several avatars.
Enjoy...
=)
P.S. I think I need to program something to limit so many frames per key
event for gtk, as a held-down arrow-up key event, which repeats quick,
plus a sudden spike in FPS can make me zoom right out of a sim at max
velocity. Obviously, this *surprise* was not an issue with polled events.
More information about the SLDev
mailing list