Rendering Optimization
Josh Flowers
joshflowers at mac.com
Tue Oct 28 16:24:45 UTC 2008
Given the actual nature of the Optimization I'd put quotes around the
word, but if memory serves Strunk or White say that's bad style.
Anyways to improve rendering in Self (changes bolded):
Update traits worldMorph's delayIfNoInputFor:
----------------------------------------------------------------------------------
| tStart |
"Details: Due the differing clock resolutions and the vissitudes
of the scheduler, the call 'times delay: n' may cause the process
to sleep for longer than n milliseconds. Thus, this method uses
the real time clock to decide when it has delayed long enough."
tStart: times real msec.
[desiredDelay > (times real msec - tStart)] whileTrue: [
eventsPending ifTrue: [ ^self ].
"Changed the 5 below to 100 to reduce time
spent idling while desktop was open"
"Changed it back to reduce time spent not rendering while desktop
was open"
times delay: 5. "ask for a small delay; typically get a longer one"
].
self
----------------------------------------------------------------------------------
and traits worldMorph's runLoop to:
----------------------------------------------------------------------------------
"Detail: Don't hog the CPU by running too fast when there is
no user input, even though there may be ongoing animation or
monitoring activities. If we get done before consuming the
desired frame time, sleep for the remainder of the time, checking
for user inputs at periodic intervals. (A refinement would be
to hang on the XEvent queue when there is no animation or
other activity happening, but the current scheme uses extremely
little CPU time when nothing is happening anyway.)"
[| computeTime. tStart |
tStart: times real msec.
stepSema signal.
stepDoneSema wait.
computeTime: times real msec - tStart.
"Changed line below from:
delayIfNoInputFor: (desiredFrameTime - computeTime) max: 0.
Right way to do this is update the 'desiredFrameTime' slot to be
10, but the inline change makes
it easier for folk to see what's going on."
delayIfNoInputFor: (10 - computeTime) max: 0.
] loop.
self
----------------------------------------------------------------------------------
Updating delayIfNoInputFor: causes an immediate jump in frame rate;
change to runLoop requires a VM restart. For me there's an magnitude
of order improvement (9 frames/sec to 100).
For any rusty in the ways of the Self (like myself) updating the
worldMorph is as easy as a, b, c:
1) Use middle mouse button to on the background and select 'New Shell'
from the menu.
2) Hit the 'E' button on the new shell.
3) In the text area type 'traits worldMorph' and hit the 'Get It'
button.
4) Twist down all the triangles: 'traits worldMorph > running >
private > UI process'
5) Update the delayIfNoInputFor: slot replacing the 100 with a 5.
6) Update the runLoop slot replacing 'desiredFrameTime' with 10.
7) Save and quit and restart.
This is all for the OS X snapshots - no idea what any other OS'
snapshots are doing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.selflanguage.org/pipermail/self-interest/attachments/20081028/a3881065/attachment.html>
More information about the Self-interest
mailing list