<br><br><div class="gmail_quote">On Tue, Mar 3, 2009 at 11:56 AM, Juan Vuletich <span dir="ltr">&lt;<a href="mailto:juan@jvuletich.org">juan@jvuletich.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Eliot,<br>
<br>
Eliot Miranda wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Juan,<div><div></div><div class="h5"><br>
<br>
On Tue, Mar 3, 2009 at 5:28 AM, Juan Vuletich &lt;<a href="mailto:juan@jvuletich.org" target="_blank">juan@jvuletich.org</a> &lt;mailto:<a href="mailto:juan@jvuletich.org" target="_blank">juan@jvuletich.org</a>&gt;&gt; wrote:<br>

<br>
    Hi Andreas,<br>
<br>
    Andreas Raab wrote:<br>
<br>
        ...<br>
<br>
        This is tricky with MessageTally. There are several issues to<br>
        keep in mind, some of which you can fix, some of which you<br>
        can&#39;t. Here we go:<br>
<br>
        1) Observing all Processes<br>
        --------------------------<br>
        First, MessageTally only observes the block you are running,<br>
        not the entire system. For example, if you were to profile this:<br>
<br>
        done := Semaphore new.<br>
        worker:= [<br>
           10 timesRepeat:[World changed; displayWorld].<br>
           done signal.<br>
        ] fork.<br>
        MessageTally spyOn:[done wait].<br>
<br>
        This is what you&#39;d get:<br>
<br>
        **Tree**<br>
        100.0% {2367ms} primitives<br>
<br>
        **Leaves**<br>
        100.0% {2367ms} UndefinedObject&gt;&gt;DoIt<br>
<br>
        Obviously it&#39;s not actually measuring what is going on during<br>
        the period of time which is a real problem if you are trying<br>
        to measure server load in general. But it&#39;s fixable.<br>
        ...<br>
<br>
    I found all this stuff very interesting and useful. Thanks!<br>
<br>
    WRT issue 1), what I&#39;d really like is the tally tree to have<br>
    several roots, one for each forked process. Otherwise, the process<br>
    that forks other processes would also have their tallies added to<br>
    him (which is wrong, as it would appear to be using more time than<br>
    it really did). Fixing this, MessageTally could give a better<br>
    insight on cpu usage than #tallyCPUUsageFor:.<br>
<br>
    To do this, I&#39;d need to find out for a certain context in the<br>
    sender chain, on which process it was running. (Then, when<br>
    building the tally tree, I could know that I need to add a new<br>
    root.) Do you know how to find out? I spent a couple of hours on<br>
    this, and it seems it is not possible...<br>
<br>
<br>
When MessageTally runs to collect each tally the process that has been interrupted is the highest priority runnable process in the runnable process lists in ProcessorScheduler.  You could implement it like this:<br>
<br>
!ProcessorScheduler methodsFor: &#39;accessing&#39; stamp: &#39;eem 3/3/2009 10:41&#39;!<br>
highestPriorityRunnableProcess<br>
[quiescentProcessLists reverseDo:<br>
[:each| each isEmpty ifFalse: [^each first]]] valueUnpreemptively.<br>
^nil<br>
<br>
&quot;| thisProcess interruptedProcess done |<br>
thisProcess := Processor activeProcess.<br>
done := false.<br>
[(Delay forSeconds: 1) wait.<br>
interruptedProcess := Processor highestPriorityRunnableProcess.<br>
done := true] forkAt: Processor userInterruptPriority.<br>
[done] whileFalse.<br>
self assert: thisProcess == interruptedProcess&quot;! !<br>
<br>
So modify MessageTally (or better still create a subclass called MultiProcessMessageTally) that uses the above to manage a set of tallies for each process found while spying.<br>
<br>
HTH<br>
<br>
</div></div></blockquote>
<br>
What you say sounds similar to what Andreas suggests to make MessageTally spy over all processes. The issue I point out is that when MessageTally<br>
builds the tree, the sender of a context might be in another process. This happens when a context forks a new process, it is still its sender. So when building the tally tree, I need to query each context for the process running it, and when it is different from the parent&#39;s one, I&#39;ll start a new tally tree.</blockquote>
<div><br></div><div>I think I see but I wouldn&#39;t put it like that.  Yes, new processes get resumed in the context of other proesses, but no, the sender is not in another process.  The bottom context of a process has no sender.  So why bother at all trying to track down in which process a process was created and leave that to the user when interpreting the profile?</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I made it work, by adding an ivar to Process to hold the firstContext (the one that is sent to #forContext:priority:). Then, when building the tally tree, for each context, I check if it is the firstContext of some process. The problem with this approach is that it adds too much overhead to the tally.</blockquote>
<div><br></div><div>IMO just throw this away.  You don&#39;t absolutely need to know on behalf of which process a process is running.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;d really appreciate a better way to do this. I&#39;m sure everybody will like the multi-process tally that would result!</blockquote><div><br></div><div>I believe the VW multi-process profiler doesn&#39;t bother identifying the parent process.  But if it does it can do so by e.g. adding an inst var to process that refers to the parent process, rather than the context in which the process was created.  But both recording the context or the parent process are bad ideas for garbage collection. </div>
<div><br></div><div>I would simply use the process name facility (Process&gt;&gt;name[:] as displayed by the process browser) to label the various tallies you collect.  If a user can&#39;t work out which process is which by just looking at the the profile ten they can change their code to use Process&gt;&gt;name: to add names to various processes and then be able to wrk it out.</div>
<div><br></div><div>just my 2<span class="Apple-style-span" style="font-family: &#39;Lucida Grande&#39;; font-size: 12px; ">¢</span></div><div><span class="Apple-style-span" style="font-family: &#39;Lucida Grande&#39;; font-size: 12px;"><br>
</span></div><div><span class="Apple-style-span" style="font-family: &#39;Lucida Grande&#39;; font-size: 12px;">best</span></div><div><span class="Apple-style-span" style="font-family: &#39;Lucida Grande&#39;; font-size: 12px;">E.</span></div>
<div><span class="Apple-style-span" style="font-family: &#39;Lucida Grande&#39;; font-size: 12px;"><br></span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>

<br>
Cheers,<br><font color="#888888">
Juan Vuletich<br>
<br>
</font></blockquote></div><br>