I can say that pharo-vm-nox --noevents --nohandlers --notimer --headless -vm-sound-null /opt/nted/image/NTed.image --no-quit eval "RFBServer stop; reset. ZnServer managedServers do: #stop. UIManager default uiProcess suspend. WorldState serverMode: true. ProcessorScheduler class compile: 'idleProcess',String cr,'[true] whileTrue: [self relinquishProcessorForMicroseconds: 10000]'. ProcessorScheduler startUp" does not make a difference at all. My assumption here is to switch everything off, don't use sockets, try to sleep as much as possible. But….nothing. Norbert
|
It's a bit more complicated and what platform you are on does matter. Just hunt in the squeak mailing list 10 years back for getNextWakeupTick
Possibly the mac vm still calls getNextWakeupTick() which returns the next time the VM has to wake up to service a delay pop. Normally that is less than 1/50 of a second out due to the Morphic polling cycle, say 16 - 20 milliseconds. The idea I had was to sleep until the VM needs to wakeup since when the ioRelinquishProcessorForMicroseconds is made we know we can sleep and the VM knows exactly when the next time to wake up is. Unfortunately we have to deal with user interrupts (i/o sockets ui) http://www.squeakvm.org/svn/squeak/branches/Cog/platforms/unix/vm/aio.c I note you can't properly calculate next wakeup tick in smalltalk code due to the rather brittle code base in the Delay logic. Attempts I made a decade back always resulted in a deadlock situation, which is why that calculation is done in the VM. I had last taken a serious look at this back in 2010 and found very strange oddities such as calling ioRelinquishProcessorForMicroseconds yet a wakeup time is now, or in the past.. Obviously one needed to explore the stack traces to understand why no process was runnable, yet a process was scheduled to be woken... Anyway compare ioRelinquishProcessorForMicroseconds Against whatever is being compiled for your target platform VM and what exactly HAVE_NANOSLEEP is when the VM is compiled. Also check idle CPU usage for say a OS X Squeak 4.2.5 VM against I'm assume a unix vm flavor as you can run both on the same os-x machine for comparison using the same image/etc. On Tue, Feb 10, 2015 at 3:03 AM, Norbert Hartl <[hidden email]> wrote:
=========================================================================== John M. McIntosh <[hidden email]> https://www.linkedin.com/in/smalltalk =========================================================================== |
In reply to this post by philippeback
Craig so how does using pthread_cond_timedwait affect socket processing? The promise of nanosleep was to wake up if an interrupt arrived say on a socket (Mind I never actually confirmed this the case, complete hearsay...) On Thu, Feb 12, 2015 at 2:40 AM, Craig Latta <[hidden email]> wrote:
=========================================================================== John M. McIntosh <[hidden email]> https://www.linkedin.com/in/smalltalk =========================================================================== |
On Thu, Feb 12, 2015 at 10:45 AM, John McIntosh <[hidden email]> wrote:
+1. What he said. The problem with pthread_cond_timed_wait, or any other merely delaying call is that, unless all file descriptors have been set up to send signals on read/writability and unless the blocking call is interruptible, the call may block for as long as it is asked, not until that or the read/writeability of the file descriptor. IMO a better solution here is to a) use epoll or its equivalent kqueue; these are like select but the state of which selectors to examine is kept in kernel space, so the set-up overhead is vastly reduced, and b) wait for no longer than the next scheduled delay if one is in progres. Of course, the VM can do both of these things, and then there's no need for a background process at all. Instead, when the V< scheduler finds there's nothing to run it calls epoll or kqueue with either an infinite timeout (if no delay is in progress) or the time until the next delay expiration. Now, if only there was more time ;-) It strikes me that the VM can have a flag that makes it behave like this so that e.g. some time in the Spur release cycle we can set the flag, nuke the background process and get on with our lives.
best,
Eliot |
I did look at using pthread_delay_np to delay the heartbeat thread as my thought was if the image is sleeping why wake up to service the clock, etc. Difficult to measure the outcome, but one should consider that option too. On Thu, Feb 12, 2015 at 10:55 AM, Eliot Miranda <[hidden email]> wrote:
=========================================================================== John M. McIntosh <[hidden email]> https://www.linkedin.com/in/smalltalk =========================================================================== |
Free forum by Nabble | Edit this page |