incubator-kie-drools icon indicating copy to clipboard operation
incubator-kie-drools copied to clipboard

Refactor and Cleanup Left and Right Tuple to address Super Cache issues

Open mdproctor opened this issue 1 year ago • 0 comments

The super cache fix work has shown a need to change how we work with certain classes and interfaces. This preliminary work moves a few places to use concrete classes and and cast where necessary. This work has demonstrated performance improvements - however, it's left the code in a place where it sometimes uses interfaces and sometimes uses concrete classes. Further, without an interface-only approach, the current code will make it impossible to do bi-linear networks, which would improve network sharing.

The following code refactors Left and Right Tuples to promote and use concrete classes everywhere. IT further centralises and expands on the Super Cache fixer code, to ensure casts are used based on switches rather than the previous chained if statements. The code reworks NodeTypeEnums, to include more information (at no extra cost), this allows a large number of instanceof uses too be removed - although it's not clear if Sink.getType or NetworkNode.getType() is slow, i.e. should we cast to BaseNode always before calling getType().

Lastly the code improves the api around LinkedLists and the supporting classes and interfaces. Making DoubleLinkedEntry extend SingleLinkedEntry and further making all classes extend those. This also results in simplifications for TupleLists.

What I will explore next is if FactHandle could now just extend TupleImpl, too, instead of using the separate LinkedTuples classes.

There should be no changes in functionality or behaviour from this code, all tests pass. However at some point some soak testing may be good, to check not regressions in performance or memory usage.

mdproctor avatar Jan 12 '24 16:01 mdproctor