I’m developing http://drupal.org/project/rules_optimization module. This would enhance the performance of current execution scheme of rule sets. And this will be integrated in Rules2.x after separate development.
Rules 2.x implements extender interfaces for faces extension in hook_rules_plugin_info. So I can provide an interface in rule set for optimization. This interface would have the optimize() method, that will be implemented in rules_optimization. Before the evaluation a database entry is made for rule sets. The optimization can be applied there(if called) and both original database entry and optimized cache entry would be made.
For the evaluation execute function is called by default by rules_invoke_rule_set. If this scheme is used for every rule set the execution can be override in hook_rules_plugin_info. But if this is not the case, i.e. selective modules are using optimization it will make trouble.
In this case what should I do? Or there can be some alternate strategy.
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | rules_optimization_integration.patch | 1.98 KB | Saubhagya |
| #35 | rules_optimization_integration.patch | 1.99 KB | Saubhagya |
| #32 | rules_optimization_integration.patch | 1.69 KB | Saubhagya |
| #29 | rules_optimization_integration-dev.patch | 1.66 KB | Saubhagya |
| #22 | rules_optimization_integration-dev.patch | 1.67 KB | Saubhagya |
Comments
Comment #1
fagoGreat to see you already started!
>And this will be integrated in Rules2.x after separate development.
We'll see, but if the solution is simple&fast, why not.
>Currently it uses ECA (event-condition-action) strategy. For a large rule sets this strategy is not optimized one.
This is not true. ECA is fine, but there is potential to optimize the evaluation strategy of rule sets in order to minimize the number of evaluated conditions.
>For the evaluation execute function is called by default by rules_invoke_rule_set. If this scheme is used for every rule set the execution can be override in hook_rules_plugin_info. But if this is not the case, i.e. selective modules are using optimization it will make trouble.
I don't see what you mean here? Well, what your patch misses is the actual $set->optimize(); call before the rule set is cached -> that's happening in the rebuildCache() method such that the implementation is actually invoked.
beside that:
* As discussed we should start with the event set only to avoid having conditions that depend on the outcome of actions. Your code though adds the method only to ususal rule sets, but not to the RulesEventSet.
* The method of the interface misses a doxygen comment. Also the doxygen of the interface should describe how it is supposed to work / when its called / what is expected to do. The interface itself could be named a bit better, I'd suggest RulesOptimizationInterface.
* The default extender class needs to reflect it's the default implementation in the name and a comment describing that.
@git:
I love using git for the patch workflow, but it has the downside that it's not integrated with the automated tests yet. So I'm fine with using git for patch development, but let's also post the patches in the issue queue such that the test bot works.
Comment #2
klausisubscribing, no patch here -> so it's active.
Comment #3
Saubhagya commentedHere is the first patch. This patch is according to above discussion. This doesn't include the interface for the modules which would provide condition containers.
Comment #5
fago* The patch seems to undo some latest changes. Always have a look at your patches to check everything is as you want before submitting them.
* Make sure the testing bot gives you a green light.
Comment #6
Saubhagya commentedComment #7
klausiwas that change intended?
trailing whitespaces
there should be a newline at the end of the file
Powered by Dreditor.
Comment #8
Saubhagya commented>was that change intended?
yes, that is intended.
Comment #10
Saubhagya commentedThe testing failed due to this code segment.
optimize() method is not implemented yet in this patch. That's why it is dev patch. After developing it in rules_optimization module it would be integrated with the patch.
Comment #11
klausiBut the goal of this patch should be a working Rules module that just allows optimization. So Rules should stay fully functional with this patch and it should be possible for your new module to easily extend/implement an optimization technique.
Comment #12
Saubhagya commentedComment #14
Saubhagya commentedComment #16
Saubhagya commentedComment #18
Saubhagya commentedComment #20
Saubhagya commentedSecond last patch
Here I'm using the faces extension to call optimize() method which is implemented in RulesOptimization and simply returns the passed $rule. Is this correct or I'm missing something because the patch having
(which is obviously wrong) gave the same errors as this one.
If any one figure out any other error please let me know.
Powered by Dreditor.
Comment #21
klausiyou want to optimize for each rule? I think one optimze() call to the whole event set should be enough.
what do you need the single rule in this case for?
Generally I would recommend that you run the Rules tests on your local Drupal installation before you submit a patch here. You can check failing tests and you can avoid the red light from the bot. Your current patch produces fatal errors.
Powered by Dreditor.
Comment #22
Saubhagya commentedComment #24
Saubhagya commented#22: rules_optimization_integration-dev.patch queued for re-testing.
Comment #26
Saubhagya commentedBut it worked correctly in my system and passed through testing module. Please anyone test it.
Comment #27
klausiobviously testbot is broken, see also another issue http://drupal.org/node/649438#comment-3078996
Comment #28
klausithe comments need some fixing - I would suggest "Interface to allow third party modules that optimize rules evaluation."
and for the function:
"Rearranges the internal structure of rules to optimize evaluation". The decision tree will be a technique that your module will apply, so a similar comment should go to your module. The interface here allows any generic optimization method that we may not even no about yet.
"Class implementing a default optimization method that is empty."
"Empty default implementation" - or something similar. Do not mention your module here, as any other module could do the optimization as well. Rules itself does not need to know which module actually optimizes.
Powered by Dreditor.
Comment #29
Saubhagya commentedComment #31
klausiwhy don't you use more of the space in one comment line and break so early?
same here
sentences in comments should end with a .
Powered by Dreditor.
Comment #32
Saubhagya commentedComment #33
klausi"Interface to allow third party modules to optimize rules evaluation." sounds better
should be "triggerable"
Powered by Dreditor.
This are just some nitpicks, I leave the final review to fago.
Comment #34
fagoThe RulesOptimizationInterface should be in the rules.core.inc somewhere near to the other interfaces there as it is not actually implementing a plugin.
>+ * Empty default implementation.
I'd call it not just empty, but say it does nothing. The default class RulesOptimization should be better named to reflect its the default behavior, e.g. use RulesDefaultOptimizer.
>+ public function optimize($rules){}
Nitpicking, but there should be space before {}.
Then the $rules parameter should be removed. First off the faces extension mechanism makes the extended object (in our case the RulesEventSet) available, so are the rules as they are children of it. Secondly, the optimization interface is with $rules bound to optimize RuleSets, without it it could be theoretically used for optimizing any plugin.
Comment #35
Saubhagya commentedComment #37
klausi$rules needs to be removed.
Powered by Dreditor.
Comment #38
Saubhagya commentedRemoved $rules parameter from $event->__call().
Comment #40
fago#38: rules_optimization_integration.patch queued for re-testing.
Comment #42
fago#38: rules_optimization_integration.patch queued for re-testing.
Comment #43
klausiAs the testbot seems to be not interested to test this finally, I mark it as RTBC as it looks good to me.
Comment #44
fagoAgreed. I wrote some additional docs, moved RulesDefaultOptimizer to rules.core.inc (plugins is only for plugins) and ran the tests myself. All fine -> committed, thanks.