[kepler-dev] Extending ProcessThread [Was Re: [kepler-cvs] kepler/src/exp/ptolemy/actor/process ProcessThread.java]

Christopher Brooks cxh at eecs.berkeley.edu
Mon Oct 24 13:53:27 PDT 2005


Hi Oscar,
I changed the cc line to include Kepler-dev because this is a somewhat
larger issue that crops up periodically.

The best answer would be for you to have read/write access to the
Ptolemy tree, make your changes, instrument the performance and check
them back in.

A slightly worse situtation would be for me to check in the changes.
Still, I'd prefer to do that than to see a copy of ProcessThread
floating around.  

Oscar Barney <oscar at sci.utah.edu> writes:

> Thanks for the input.  The reason for modifying this class is a simple 
> one (only one line added).  When Ilkay and I sat down to discuss the 
> ProvenanceListener we thought it may be helpful for debugging if it 
> logged when each actor was about to fire.  Thus i added one line to 
> processthread to send a notification of this.  I dont think modifying 
> the baseclass or making a subclass would achieve the desired effect. 

Perhaps we could attach a listener here and use the debug mechanism
that we use for actors?  I'd have to look at what the change you would
like to make is, but I can't spend lots of time on this because I'm on
a bomb run to ship the Ptolemy TinyOS release next week.

> Matt warned me I would have to update this allot.  The goal would be to 
> get the Provenance Recorder working well enough so that we could check 
> it directly into the Ptolemy Tree and avoid these updates (i think its 
> close).
>
> Another alternative is to leave ProcessThread alone and just go without 
> this added notification.  The benefit of this notification in PN is 
> debatable anyway since it is asynchronous.

Modifying the baseclass so that you can register a method that does
what you want is probably the right thing here.

> Question:  The stuff i checked in wont break things but i do have one 
> concern with it.  We wanted to log tokens sent from here to there and so 
> we have added a few extra function calls every time send,broadcast,etc. 
> is called in IOPort.  Do you think this will cause a performance 
> slowdown people will notice?

Well, performance measuring is probably the way to go. You know the
 drill: Do a test before, do a test after.

In the director, we typically set a _debug flag and then check its
value before calling a more expensive method.  So we do:

    if (_debug) {
        debug("The flay rods gone" + "askew " + "off the treadle");
    }

The advantage is that if _debug is false, then hopefully the debug()
method arguments never get concatenated and hopefully debug() never
gets called.

Furthermore, some compilers are smart enough to not even include
the debug() call if _debug is declared final and set to false.
We can't always use this since we want the user to be able to enable
debugging at runtime, but it can be a win.

So, think about ways to add a hook for what you want.  If you send a
diff of what the change is, maybe someone will have an idea.

Sorry to be a little prickly about this, but ProcessThread is a fairly
gnarly class and I'd hate to see a copy of it running around.

_Christopher

> Let me know... thanks again!
> 
> Oscar
> 
> 
> 
> Christopher Brooks wrote:
> 
> >Hi Oscar,
> >Perhaps you could either just subclass ptolemy.actor.process.ProcessThread
> >or modify the baseclass and then subclass?
> >
> >The problem is that if you copy and paste ProcessThread from the
> >ptolemy tree, then you will probably not get any of the updates that
> >we are in the process (haha) of making.
> >
> >Edward Lee and Thomas Feng have been poking around in ProcessThread,
> >so it might be worth making changes in the Ptolemy base class if
> >necessary.  
> >I can fairly easily give you write access to the Ptolemy tree.
> >
> >Just my $0.0.2
> >
> >_Christopher
> >
> >Christopher Brooks (cxh at eecs berkeley edu) University of California
> >Programmer/Analyst Chess/Ptolemy/Trust        US Mail: 558 Cory Hall #1770
> >ph: 510.643.9841 fax:510.642.2739	      Berkeley, CA 94720-1770
> >home: (F-Tu) 707.665.0131 (W-F) 510.655.5480  (office: 400A Cory)
> >
> >
> >
> >--------
> >
> >    barney      05/10/24 10:30:02
> >    
> >      Added:       src/exp/ptolemy/actor/process ProcessThread.java
> >      Log:
> >      added so that the ProvenanceExecution listener can know when an actor in
>      
> >   PN or other domain using this class is about to fire.
> >      
> >      Revision  Changes    Path
> >      1.1                  kepler/src/exp/ptolemy/actor/process/ProcessThread.
>     j
> >   ava
> >      
> >
<


More information about the Kepler-dev mailing list