Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> Agent vs. Rules and CPU efficiency
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1224176118

Message started by Allan Tsai on Oct 16th, 2008, 12:55pm

Title: Agent vs. Rules and CPU efficiency
Post by Allan Tsai on Oct 16th, 2008, 12:55pm

I want to implement some complex conditional actions based on attribute values.

Is it better to put the complexity at the note level by adding it to the Rule section of a note prototype, or should I try to move the complexity to a set of agents?

For example: I have a user attribute named "due" of type "date." If due=today a want to color the note and move it to another container. But if i want to change the "due" date of a note where due already = today, TB will reverse the coloring and move it to a different container.

Do notes constantly check their Rules like agents do? Or do they only check when an attribute changes? I know that Agents check constantly depending on their priority. Which is more efficient CPU-wise?

Are there other pitfalls of doing one or the other?

Title: Re: Agent vs. Rules and CPU efficiency
Post by Mark Bernstein on Oct 16th, 2008, 3:10pm

You can switch agents off, and you can reduce the priority of individual agents. You can't do that with rules.

Agents always start by looking at every note.  But a Rule only looks at one note -- itself.  Sometimes, it's easier to attach a rule to a small number of notes than to write an agent.

The new AgentManager in Tinderbox 4.5 makes agent updates just about as efficient as rules.

Title: Re: Agent vs. Rules and CPU efficiency
Post by Allan Tsai on Oct 16th, 2008, 8:09pm

Am I correct in thinking then that having one or more agents  perform functions on notes is more efficient than having a bunch of notes checking their own complex rules?

I'm just worried about crippling the performance of a document with a bunch of notes with complex notes running around.

Title: Re: Agent vs. Rules and CPU efficiency
Post by Mark Bernstein on Oct 17th, 2008, 11:48am

It depends completely on what you're doing.  

When lots of notes have rules, those rules tend to be inherited from prototypes -- and so they're only compiled once.  But agents can often be very specific -- a query like "#inside(NewBooks)" runs quickly if NewBooks is a small container.

A little algorithmic analysis will go a long way here. How many notes will your rules need to examine?  How many notes will your agents need to examine?  How complex is the condition that they'll be checking?  

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.