Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
Tinderbox Users >> Agent, Actions, Rules & Automation >> Seeking suggestions on efficacy

Message started by Barbara Snyder on Apr 16th, 2015, 3:25pm

Title: Seeking suggestions on efficacy
Post by Barbara Snyder on Apr 16th, 2015, 3:25pm

I have a prototype with a rule that sets the category/categories of a note depending on its name. So for example if I name a note "edit xyz for someClient" the category might be set to "editing;someClient". In order for me to be able to manually override this rule, the whole rule is encased in an "if category ==""" statement. Therefore, this rule only has to run when the note is first created and named, or if I edit the name and delete the categories, to force it to be evaluated again.

However, because it's a rule in a prototype, it's running all the time. This seems like a waste of processing time/energy. I guess I now have 125 notes, because the Inspector is showing that I have 125 rules running. And if I start creating agents, it will be running on all the aliases as well.

Maybe I shouldn't worry about it, but I am curious as to how I might go about modifying my file structure so the rule isn't constantly running, if possible. A parent action doesn't work, because the rule needs to run after the note is named, not when it is added to the parent.

If I shouldn't worry about it, let me know that too, please.

Thanks -- Barbara

Title: Re: Seeking suggestions on efficacy
Post by Barbara Snyder on Apr 16th, 2015, 3:59pm

I should add that I would like it to be automatic, rather than having to use a stamp to set the categories via my rule every time I add a note.


Title: Re: Seeking suggestions on efficacy
Post by Mark Bernstein on Apr 16th, 2015, 4:40pm

This isn't necessarily a bad approach. But Tinderbox 6.2 introduces a new kind of rule, the Edict, which runs much less frequently than rules.  

Edicts run when the document is loaded, and occasionally thereafter -- right now, they run about once an hours. So, if you don't need to set your categories right away, Edicts may be right for you.

You might also consider OnAdd actions, if many or all of this sort of note occur in one container, or in one kind of container.

Title: Re: Seeking suggestions on efficacy
Post by Barbara Snyder on Apr 16th, 2015, 5:49pm

Thanks, Mark, but I do want the categories to be set right away, so that anytime I look at my Attr Browser window that summarizes where I'm spending my time, it will be current.

OnAdd won't work - that's what I meant when I said "parent action" in my original post. The category gets set after OnAdd processing is done - after I type the name of the note and hit Return. I tested it.

Is there (or might there be at some point) a kind of Run Edicts Now command, maybe analogous to Update Agents Now? That might be the best of both worlds. I could just run the Edicts when I need to see my summary info.

For now, I'll just go with what I've got.

Thanks -- Barbara

Title: Re: Seeking suggestions on efficacy
Post by Mark Anderson on Apr 17th, 2015, 3:57am

Why not use an agent? Your notes of interest are prototyped so that gives you an easy query to find them. Once the agent is made and run you can alter the priority or even turn it off until your next edit session. This allows you to tweak performance.

It might be useful to see your rule too.  If you are using .contains() to search for stem words in $Name to set your categories, that's a lot of overhead as you're constantly running regexs. If so, all the more to try and ensure the process only runs when needed.

Title: Re: Seeking suggestions on efficacy
Post by Barbara Snyder on Apr 18th, 2015, 7:15pm

Hi --

OK I am trying an agent. My rule does indeed contain a series of about 40 or so if statements, and yes, they are all .contains() looking at $Name. if $Name.icontains("abc) then $category = $category+"xyz" etc. So I moved all that into the agent.

Of course, now my (streamlined) rule run on almost twice as many notes, because it runs on all the originals plus all the aliases collected by the agent. And I still need other parts of the rule that calculate other values, e.g. it sets the end time of one note based on the start time of the next note, but I guess that will not use as much processing power. And now that I think about it, I might be able to move some of that processing into the onAdd statement. Maybe I'll play with that.

Thanks for the help -- Barbara

Title: Re: Seeking suggestions on efficacy
Post by Mark Anderson on Apr 19th, 2015, 7:49am

You shouldn't need the rule and the agent action as the latter should replace the former. The idea of using an agent is so you don't have so many rules running.  The agent action uses the alias but changes the original, unless the target attributes are intrinsic (i.e. separate for aliases such as $Width or $Container).

Or, you can split the rule so lightweight stuff is in a rule (or pushed to an $OnAdd as you mention) and the heavyweight stuff goes in the agent.

Title: Thoughts on efficiency
Post by Mark Bernstein on Apr 19th, 2015, 12:58pm

Backing up a level: what is the underlying concern here?  Why do we want efficiency?

Some possibilities might include:

  • Preferring less delay between making a change and seeing Tinderbox respond to the change.
  • Preferring to reduce power consumption.
  • Concerns over interference with other CPU-hungry processes.
  • Traffic jams, where Tinderbox can't finish evaluating all the rules before it's time to start over again.
  • Something else.

My impression is that, for most projects and most people, none of these concerns are likely to matter. So, most of the time, efficiency is good for style points and thatís about all.

Agents tend to do less computational work than rules, and edicts do less computational work than agents.  This can matter for battery life or for interference with other processes, things that might be a concern, for example, if (a) you spend a lot of time on intercontinental flights, or (b) you're a professional film editor and you're working on location.

The problem of traffic jams used to be real. I've heard of only one potential case with Tinderbox Six, though, and unless you're doing really wild things with rules, it's not going to be a problem for you.

But, also, it's always satisfying to do things well. There's no point in making your computer do more work than necessary; it doesnít care one way or another, but it's nicer to say

    inside(/archives) & $Text.contains(....some complex expression....)

where we reject 95% of the cases instantly because theyíre not in the archives, than the equivalent

    $Text.contains(....some complex expression....) & inside(/archives)

where we do lots of work to find notes with a complicated expression, but often then throw it away because, no, that note isn't inside archives so never mind.  Our slaves of sand and steel donít actually care either way, but our sympathy suggests that it's better not to do the extra work.

Title: Re: Seeking suggestions on efficacy
Post by Barbara Snyder on Apr 19th, 2015, 3:19pm

Thanks, yes I was planning to split up the rule and agent as you mentioned, with the heavy lifting in the agent. My initial efforts were unsuccessful but I think that was just user error and I might try again.

As to the underlying reason, that was part of my original question. Should I even care about being efficient? In this case, with a file that will likely never contain more than several thousand very short notes (say an average of 10-15 a day, most of them with no text) it's probably moot. But I'm glad I asked because I learned a lot from your responses.

-- Barbara

Title: Re: Seeking suggestions on efficacy
Post by Mark Anderson on Apr 19th, 2015, 5:29pm

Now we've unpicked the overall issue of efficiency in performance terms, I'd suggest that a rule/agent/edict needing 40 if() clauses is a prompt for some refactoring.

It sounds like you effectively have a controlled vocabulary of 40 categories (which may rise or fall a bit over time). Consider the suggestions here about pre-populating a list. With that set up then pretty easy to either:
  • Manually set the category from a drop down when the note is made, or if automation is still a must,
  • values("category") gives you list of all unique $category values which can then be iterated via list.each.
The latter would give some flex even if you still end up doing .contains() searches as the list will vary as the list of $category changes over time.

The context where you use that list - in terms of rule/edict/agent action - is up to the user  and has already been discussed above.

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.