On Sat, May 14, 2022 at 07:15:45PM +0200, Michael Storz wrote:
>
> Despite all these changes, however, I still see room for improvement. At the
> moment I'm not very happy about how the do_meta_tests subroutine is
> implemented. It seems to work now, but the query for the dependency of the
> meta rules looks too complicated to me:
>
> foreach my $r (@{$md->{$rulename}|[]}) {
> next RULE unless exists $h->{$r} && !$tp->{$r} && !$pl{$r};
> }
>
> Instead of three dependencies, there should really only be one query at this
> point for "is the rule ready or not". If we knew exactly the state of a rule
> at each point in time, then it would also be possible to move from a brute
> force algorithm to a deterministic algorithm, where a rule that becomes
> ready automatically sets all meta rules to ready if that rule was the last
> dependency analogous to the algorithm for tags. do_meta_tests would then
> simply process a queue of ready meta rules. If a new meta rule is ready it
> will be added to the end of the queue. If the queue is empty, all rules of a
> priority class are processed.
I heartily agree with everything. The problem is that I don't have any
formal programming training or knowledge of fancy algorithms or
deterministic stuff. Frankly I'm not even interested in most of that stuff,
I just script and try to make things do stuff correctly with some common
sense and logic, would be happy if someone showed how to make it simpler.
Glad I was able to make it work with maybe 10% performance loss, but it's
balanced back by dumb metas not needing to wait for async stuff for no
reason etc.