Tinderbox Forum

Does rule/edict etc processing time benefit from absolute paths in action code?

I tend to be lazy and use note names if they are unique, but am wondering if using fully pathed references (or $IDs for that matter) make any difference to the speed of the rule/edict etc firing. I tried to figure out a way to test it, but couldn’t come up with anything that seemed practical.

Thanks in advance if anyone knows.

The safest method, if you are going to use actions involving offsets is to use unique note titles (i.e. $Name). In some cases that isn’t feasible. Tinderbox is perfectly happy to have multiple notes with the same title, as each note has a unique $ID value. However, queries and actions use titles (or fill paths)

† What are ‘offsets’? this is where you want to refer in a query, or action, to another note by name or path. This:

$Color = $Color("Some note");

Sets the current note’s $Color to the $Color value used in a note called “Some note”. But if “Container A” and “Container B” both have a note called “some note” we can use the full path instead (i.e. $path instead of $Name) as our offset:

$Color = $Color("/Container A/Some note");

It is possible to use a note’s $Id as an offset reference (see here) though I’d suggest only doing so if there is no easier way to avoid the situation.

The above holds true, but I realise I mis-answered the question. The time issue is moot, as if the $Name is unique then there is a match. I don’t believe that matching a $name vs a $Path value has a noticeable time difference in any normal document (i.e. I’m sure one might think of a special case where it might matter but your chances of meeting that are slim to non-existent).

I should have added that where multiple matches could occur (i.e $Name is not unique), a query or action will use the first matching item by $OutlineOrder. In some cases, that fact can be used to benefit. However, if you know you are using non-unique names ity is safer to use a path value without worrying about performance.

The main reason people use a the title rather than the full path is it’s less typing and you generally don’t need to look up the $Name but you might need to do so for the $Path.

2 Likes

The performance difference between a full path and a unique name is unlikely to matter in any context other than a find() or collect() running on a very large document. Even then, I’m not sure this would make any difference.

Note that rules and edicts currently fire on a fixed schedule. You can’t speed them up. The exception, which very few people have ever seen, occurs when Tinderbox can’t finish all its rules before it’s time to run the next batch of rules.

2 Likes

Thanks for the info. Just clarifying, does the Run Now button on the Rule and Edict tabs run just that rule/edict, effectively stopping the schedule that’s underway and firing the one just clicked before resuming its usual routine?

Pretty much. It adds a single task for that rule to the queue. If the queue is already full of work, the pending work still gets done first. I’ve seldom seen that; if it’s a problem at some point, we could cancel most pending work.

2 Likes

I’ve updated my notes on Rule Inspector and Edict Inspector.

As the rule/edict ‘run now button’ is disabled id the $RuleDisabled or $EdictDisabled tick-box is set, it seems the ‘run now’ button has little real effect for a rule, which runs next cycle anyway. Rule have no throttling and are always on (every cycle) or off. However, for an edict that at most might not run for about an hour the button is extremely useful.