SlideShare a Scribd company logo
1 of 32
Download to read offline
Mark Proctor
Chief Architect - Rules, BPM, Optimisation
Red Hat
Reducing the Cost of the Linear Growth Effect using
Adaptive Rules with Unlinking and Lazy Rule
Evaluation
Introduction
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
The Problem
• Acharya (Scaling up production system 1994) 3 areas:
• Taming the combinatorial explosion
• Improved memory subsystem performance
• Eliminating linear average growth effect
• Wasted work
The Proposed Solution
• Adaptive Rule Network via rule unlinking
• Network sharing
• Lazy rule evaluation
• Isolated rules
• Set Propagation
• Batching of work
Introduction
Background
Rete
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
Rete
Classes
Account
long accountNo
int balance
CashFlow
Date date
int amount
AccountPeriod
Date start
Date end
Rete
select * from Account acc,
Cashflow cf, AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT
cf.date >= ap.start and
cf.date <= ap.end
rule “increase balance for AccountPeriod Credits”
when
ap : AccountPeriod()
acc : Account()
cf : CashFlow( type == CREDIT,
accountNo == acc.accountNo,
date >= ap.start && <= ap.end )
then
acc.balance += cf.amount;
end
acc.balance += cf.amount
Rete
select * from Account acc,
Cashflow cf, AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT
cf.date >= ap.start and
cf.date <= ap.end
rule “increase balance for AccountPeriod Credits”
when
ap : AccountPeriod()
acc : Account()
cf : CashFlow( type == CREDIT,
accountNo == acc.accountNo,
date >= ap.start && <= ap.end )
then
acc.balance += cf.amount;
end
acc.balance += cf.amount
Rete
select * from Account acc,
Cashflow cf, AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT
cf.date >= ap.start and
cf.date <= ap.end
rule “increase balance for AccountPeriod Credits”
when
ap : AccountPeriod()
acc : Account()
cf : CashFlow( type == CREDIT,
accountNo == acc.accountNo,
date >= ap.start && <= ap.end )
then
acc.balance += cf.amount;
end
acc.balance += cf.amount
Rete
select * from Account acc,
Cashflow cf, AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT
cf.date >= ap.start and
cf.date <= ap.end
rule “increase balance for AccountPeriod Credits”
when
ap : AccountPeriod()
acc : Account()
cf : CashFlow( type == CREDIT,
accountNo == acc.accountNo,
date >= ap.start && <= ap.end )
then
acc.balance += cf.amount;
end
acc.balance += cf.amount
Rete
select * from Account acc,
Cashflow cf, AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT
cf.date >= ap.start and
cf.date <= ap.end
rule “increase balance for AccountPeriod Credits”
when
ap : AccountPeriod()
acc : Account()
cf : CashFlow( type == CREDIT,
accountNo == acc.accountNo,
date >= ap.start && <= ap.end )
then
acc.balance += cf.amount;
end
acc.balance += cf.amount
Rete
rule "Increase balance for AccountPeriod Credits"

when

ap : AccountPeriod( )

acnt : Account( )

cf : CashFlow( type == CashFlowType.CREDIT,

accountNo == acnt.accountNo,

date >= ap.start && <= ap.end )

then

modify(acnt) {
balance = acnt.balance + cf.amount;
}

end
rule "Decrease balance for AccountPeriod Debits"

when

ap : AccountPeriod( )

acnt : Account( )

cf : CashFlow( type == CashFlowType.DEBIT,
accountNo == acnt.accountNo,
date >= ap.start && <= ap.end )

then

modify(acnt) {
balance = acnt.balance - cf.amount
}

end
CashFlow
date amount type accountNo
12-Jan-12 100 CREDIT 1
2-Feb-12 200 DEBIT 1
18-May-12 50 CREDIT 1
9-Mar-12 75 CREDIT 1
AccountingPeriod
start end
01-JAN-2012 31-MAR-2012
Account
accountNo balance
1 0
CashFlow
date amount type accountNo
12-Jan-12 100 CREDIT 1
9-Mar-12 75 CREDIT 1
CashFlow
date amount type accountNo
2-Feb-12 200 DEBIT 1
Account
accountNo balance
1 -25
Rete
rule "Print balance for AccountPeriod" salience -50

when

ap : AccountPeriod()

acnt : Account( )

then

System.out.println( "Account Number " + acnt.accountNo +
" balance " + acnt.balance );

end
Agenda
1 increase balance
arbitrary2 decrease balance
3 increase balance
4 print balance
Rete
Root
Alpha Node
Left Input Adapter Node
Join Node
Terminal Node
Root
Account Period Account Cashflow
type == Credit type == Debit
Credit DebitPrint
LIA
Alpha Network
Beta Network
Shared Network
Background
Related Research
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• Treat (Miranker 1987)
• Adaptive Networks
• ’rule-active’ flag.
• Linear time cost
• Rete/UL (Doorenbos 1994)
• left and right unlinking
Related Research
Root
Account Period Account Cashflow
type == Credit type == Debit
Credit DebitPrint
LIA
Alpha Network
Beta Network
Solution
Segmentation
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• R1 = A B C
• R2 = A D E
• R3 = A B D E
Segmentation
A
C
R1
B B
C
D
E
A
R1 R2
D
E
C
A
B
R1 R3
• R1 = A B C
• R3 = A B D E
• R4 = A B D F G
Segmentation
D
E
C
A
B
R1
R3
F
G
R4
• R1 = A not ( B not ( C ) ) D
• R2 = A B C
Segmentation
A
D
R1
Not B
Not
C
R2
Solution
Bitmask
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• R1 = A B C
• R2 = A D E
Bitmask
A
C
R1
B
1
2
4 1
B
C
D
E
A
R1 R2
1
1
2
2
1
2
1
2
1
• R1 = A B C
• R3 = A B D E
• R4 = A B D F G
Bitmask
D
E
C
A
B
R1
R2
F
G
R3
1
2
4
1
2
• R1 = A not ( B not ( C ) ) D
• R2 = A B C
Bitmask
A
D
R1
Not B
Not
C
C
R2
1
2
4
Solution
Runtime
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• 3 Levels of Memory
• Beta
• Segment
• Rule
Runtime
Rule Memory
Segment Memory
Node
Memory
Node
Memory
Node
Memory
Segment Memory
Node
Memory
Node
Memory
Node
Memory
Segment Memory
Node
Memory
Node
Memory
Node
Memory
Segment Memory
Node
Memory
Node
Memory
Node
Memory
Rule Memory Rule Memory Rule Memory
• Linked rules are scheduled for evaluation
• Lazy rule evaluation
• Split Alpha and Beta network evaluation
• Necessary to ensure all possible rules are scheduled,
before evaluation happens.
• Better batch evaluation
• Set Propagation
• Better batch evaluation
• Eventual support for parallel joins and collection-
oriented match (Tambe 1993)
Runtime A
D
R1
Not B
Not
C
C
R2
1
2
4
Benchmark
Implementation
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• Both algorithms share large amounts of code
• discrimination tree, expression evaluations, tuple data structures. Lazy rules adds
the propagation set around exist Tuple and alternative rule evaluation code.
• Parameterised benchmarks
• Segments and fan-out, nodes per segment and number of facts.
• Number of facts was maxed at 32.
• All rules generated with expressions so all join attempts match.
• JMH Harness with suitable warmups and execution times.
• 4 Benchmarks
• Match And Fire All Rules
• Repeat First Rule Fire
• Repeat Last Rule Fire
• Iterate And Fire All Rules
Benchmark
Conclusion
Results
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• Match And Fire All Rules.
• Expected similar results, as no wasted 

work. However lazy was twice as fast
• and growing.
• Conf 5 is 25.9% to 74.1%
• Repeat First Rule Fire.
• 3.8% to 96.2% for conf 5.
• Can see Rete getting slower as more
• rules added. GC also an impact.
• Repeat Last Rule Fire.
• Same as ^
• Iterate And Fire All Rules.
• 16.7% to 83.3%. Set Propagation larger

impact than expected.
Results
ms/op percentage stack
ms/op
ms/op
ms/op
percentage stack
percentage stack
percentage stack
Conclusion
Future work
• Introduction
• Background
• Rete
• Related
Research
• Solution
• Segmentation
• Bitmask
• Runtime
• Benchmark
• Implementation
• Conclusion
• Results
• Future Work
• Alpha network unlinking, to have same advantages of
Rete/UL on large fanouts.
• Improved linking heuristics, such as arc consistency
•
Future Work

More Related Content

Similar to Reducing the Cost of the Linear Growth Effect using Adaptive Rules with Unlinking and Lazy Rule Evaluation (ODBase 2018)

Metrics-Based Process Mapping
Metrics-Based Process MappingMetrics-Based Process Mapping
Metrics-Based Process MappingTKMG, Inc.
 
Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1khairulhuda242
 
Kanban – Visualizing the value chain
Kanban – Visualizing the value chain Kanban – Visualizing the value chain
Kanban – Visualizing the value chain Avarteq
 
DS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfDS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfMidhunM83
 
Enhancements on Spark SQL optimizer by Min Qiu
Enhancements on Spark SQL optimizer by Min QiuEnhancements on Spark SQL optimizer by Min Qiu
Enhancements on Spark SQL optimizer by Min QiuSpark Summit
 
Performance OR Capacity #CMGimPACt2016
Performance OR Capacity #CMGimPACt2016 Performance OR Capacity #CMGimPACt2016
Performance OR Capacity #CMGimPACt2016 Alex Gilgur
 
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, EuropePatterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, EuropeFlip Kromer
 
day 3-2 PMP.pptx
day 3-2 PMP.pptxday 3-2 PMP.pptx
day 3-2 PMP.pptxAhmedKayed6
 
Wayfair-Data Science Project
Wayfair-Data Science ProjectWayfair-Data Science Project
Wayfair-Data Science ProjectMehnaz Maharin
 
Basics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow DevicesBasics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow DevicesArrow Devices
 
CAD: Layout Extraction
CAD: Layout ExtractionCAD: Layout Extraction
CAD: Layout ExtractionTeam-VLSI-ITMU
 
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...HostedbyConfluent
 
Understanding printed board assembly using simulation with design of experime...
Understanding printed board assembly using simulation with design of experime...Understanding printed board assembly using simulation with design of experime...
Understanding printed board assembly using simulation with design of experime...Kiran Hanjar
 
Finit formula and business rule efficiency in one stream
Finit   formula and business rule efficiency in one streamFinit   formula and business rule efficiency in one stream
Finit formula and business rule efficiency in one streamfinitsolutions
 
Benchmarking Elastic Cloud Big Data Services under SLA Constraints
Benchmarking Elastic Cloud Big Data Services under SLA ConstraintsBenchmarking Elastic Cloud Big Data Services under SLA Constraints
Benchmarking Elastic Cloud Big Data Services under SLA ConstraintsNicolas Poggi
 
Data Stream Management
Data Stream ManagementData Stream Management
Data Stream Managementk_tauhid
 
(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis
(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis
(ARC310) Solving Amazon's Catalog Contention With Amazon KinesisAmazon Web Services
 
EM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM MetricsEM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM MetricsMaaz Anjum
 
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...Amazon Web Services
 

Similar to Reducing the Cost of the Linear Growth Effect using Adaptive Rules with Unlinking and Lazy Rule Evaluation (ODBase 2018) (20)

Metrics-Based Process Mapping
Metrics-Based Process MappingMetrics-Based Process Mapping
Metrics-Based Process Mapping
 
Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1
 
Kanban – Visualizing the value chain
Kanban – Visualizing the value chain Kanban – Visualizing the value chain
Kanban – Visualizing the value chain
 
Credit risk meetup
Credit risk meetupCredit risk meetup
Credit risk meetup
 
DS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfDS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdf
 
Enhancements on Spark SQL optimizer by Min Qiu
Enhancements on Spark SQL optimizer by Min QiuEnhancements on Spark SQL optimizer by Min Qiu
Enhancements on Spark SQL optimizer by Min Qiu
 
Performance OR Capacity #CMGimPACt2016
Performance OR Capacity #CMGimPACt2016 Performance OR Capacity #CMGimPACt2016
Performance OR Capacity #CMGimPACt2016
 
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, EuropePatterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
 
day 3-2 PMP.pptx
day 3-2 PMP.pptxday 3-2 PMP.pptx
day 3-2 PMP.pptx
 
Wayfair-Data Science Project
Wayfair-Data Science ProjectWayfair-Data Science Project
Wayfair-Data Science Project
 
Basics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow DevicesBasics of Functional Verification - Arrow Devices
Basics of Functional Verification - Arrow Devices
 
CAD: Layout Extraction
CAD: Layout ExtractionCAD: Layout Extraction
CAD: Layout Extraction
 
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
 
Understanding printed board assembly using simulation with design of experime...
Understanding printed board assembly using simulation with design of experime...Understanding printed board assembly using simulation with design of experime...
Understanding printed board assembly using simulation with design of experime...
 
Finit formula and business rule efficiency in one stream
Finit   formula and business rule efficiency in one streamFinit   formula and business rule efficiency in one stream
Finit formula and business rule efficiency in one stream
 
Benchmarking Elastic Cloud Big Data Services under SLA Constraints
Benchmarking Elastic Cloud Big Data Services under SLA ConstraintsBenchmarking Elastic Cloud Big Data Services under SLA Constraints
Benchmarking Elastic Cloud Big Data Services under SLA Constraints
 
Data Stream Management
Data Stream ManagementData Stream Management
Data Stream Management
 
(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis
(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis
(ARC310) Solving Amazon's Catalog Contention With Amazon Kinesis
 
EM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM MetricsEM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM Metrics
 
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
AWS re:Invent 2016| DAT318 | Migrating from RDBMS to NoSQL: How Sony Moved fr...
 

More from Mark Proctor

Rule Modularity and Execution Control
Rule Modularity and Execution ControlRule Modularity and Execution Control
Rule Modularity and Execution ControlMark Proctor
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationMark Proctor
 
Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)
Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)
Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)Mark Proctor
 
Learning Rule Based Programming using Games @DecisionCamp 2016
Learning Rule Based Programming using Games @DecisionCamp 2016Learning Rule Based Programming using Games @DecisionCamp 2016
Learning Rule Based Programming using Games @DecisionCamp 2016Mark Proctor
 
Drools Happenings 7.0 - Devnation 2016
Drools Happenings 7.0 - Devnation 2016Drools Happenings 7.0 - Devnation 2016
Drools Happenings 7.0 - Devnation 2016Mark Proctor
 
RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning Mark Proctor
 
Red Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire RoadmapsRed Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire RoadmapsMark Proctor
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyMark Proctor
 
Classic Games Development with Drools
Classic Games Development with DroolsClassic Games Development with Drools
Classic Games Development with DroolsMark Proctor
 
Drools and jBPM 6 Overview
Drools and jBPM 6 OverviewDrools and jBPM 6 Overview
Drools and jBPM 6 OverviewMark Proctor
 
Drools and BRMS 6.0 (Dublin Aug 2013)
Drools and BRMS 6.0 (Dublin Aug 2013)Drools and BRMS 6.0 (Dublin Aug 2013)
Drools and BRMS 6.0 (Dublin Aug 2013)Mark Proctor
 
UberFire Quick Intro and Overview (early beta Aug 2013)
UberFire Quick Intro and Overview (early beta Aug 2013)UberFire Quick Intro and Overview (early beta Aug 2013)
UberFire Quick Intro and Overview (early beta Aug 2013)Mark Proctor
 
What's new in Drools 6 - London JBUG 2013
What's new in Drools 6 - London JBUG 2013What's new in Drools 6 - London JBUG 2013
What's new in Drools 6 - London JBUG 2013Mark Proctor
 
Property Reactive RuleML 2013
Property Reactive RuleML 2013Property Reactive RuleML 2013
Property Reactive RuleML 2013Mark Proctor
 
Reactive Transitive Closures with Drools (Backward Chaining)
Reactive Transitive Closures with Drools (Backward Chaining)Reactive Transitive Closures with Drools (Backward Chaining)
Reactive Transitive Closures with Drools (Backward Chaining)Mark Proctor
 
Drools 6.0 (JudCon 2013)
Drools 6.0 (JudCon 2013)Drools 6.0 (JudCon 2013)
Drools 6.0 (JudCon 2013)Mark Proctor
 
Drools 6.0 (CamelOne 2013)
Drools 6.0 (CamelOne 2013)Drools 6.0 (CamelOne 2013)
Drools 6.0 (CamelOne 2013)Mark Proctor
 
UberFire Quick Intro and Overview (early beta Jul 2013)
UberFire Quick Intro and Overview (early beta Jul 2013)UberFire Quick Intro and Overview (early beta Jul 2013)
UberFire Quick Intro and Overview (early beta Jul 2013)Mark Proctor
 
UberFire (JudCon 2013)
UberFire (JudCon 2013)UberFire (JudCon 2013)
UberFire (JudCon 2013)Mark Proctor
 
Drools 6.0 (Red Hat Summit 2013)
Drools 6.0 (Red Hat Summit 2013)Drools 6.0 (Red Hat Summit 2013)
Drools 6.0 (Red Hat Summit 2013)Mark Proctor
 

More from Mark Proctor (20)

Rule Modularity and Execution Control
Rule Modularity and Execution ControlRule Modularity and Execution Control
Rule Modularity and Execution Control
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentation
 
Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)
Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)
Drools, jBPM and OptaPlanner (NYC and DC Sept 2017 - Keynote Talk Video)
 
Learning Rule Based Programming using Games @DecisionCamp 2016
Learning Rule Based Programming using Games @DecisionCamp 2016Learning Rule Based Programming using Games @DecisionCamp 2016
Learning Rule Based Programming using Games @DecisionCamp 2016
 
Drools Happenings 7.0 - Devnation 2016
Drools Happenings 7.0 - Devnation 2016Drools Happenings 7.0 - Devnation 2016
Drools Happenings 7.0 - Devnation 2016
 
RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning
 
Red Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire RoadmapsRed Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
 
Classic Games Development with Drools
Classic Games Development with DroolsClassic Games Development with Drools
Classic Games Development with Drools
 
Drools and jBPM 6 Overview
Drools and jBPM 6 OverviewDrools and jBPM 6 Overview
Drools and jBPM 6 Overview
 
Drools and BRMS 6.0 (Dublin Aug 2013)
Drools and BRMS 6.0 (Dublin Aug 2013)Drools and BRMS 6.0 (Dublin Aug 2013)
Drools and BRMS 6.0 (Dublin Aug 2013)
 
UberFire Quick Intro and Overview (early beta Aug 2013)
UberFire Quick Intro and Overview (early beta Aug 2013)UberFire Quick Intro and Overview (early beta Aug 2013)
UberFire Quick Intro and Overview (early beta Aug 2013)
 
What's new in Drools 6 - London JBUG 2013
What's new in Drools 6 - London JBUG 2013What's new in Drools 6 - London JBUG 2013
What's new in Drools 6 - London JBUG 2013
 
Property Reactive RuleML 2013
Property Reactive RuleML 2013Property Reactive RuleML 2013
Property Reactive RuleML 2013
 
Reactive Transitive Closures with Drools (Backward Chaining)
Reactive Transitive Closures with Drools (Backward Chaining)Reactive Transitive Closures with Drools (Backward Chaining)
Reactive Transitive Closures with Drools (Backward Chaining)
 
Drools 6.0 (JudCon 2013)
Drools 6.0 (JudCon 2013)Drools 6.0 (JudCon 2013)
Drools 6.0 (JudCon 2013)
 
Drools 6.0 (CamelOne 2013)
Drools 6.0 (CamelOne 2013)Drools 6.0 (CamelOne 2013)
Drools 6.0 (CamelOne 2013)
 
UberFire Quick Intro and Overview (early beta Jul 2013)
UberFire Quick Intro and Overview (early beta Jul 2013)UberFire Quick Intro and Overview (early beta Jul 2013)
UberFire Quick Intro and Overview (early beta Jul 2013)
 
UberFire (JudCon 2013)
UberFire (JudCon 2013)UberFire (JudCon 2013)
UberFire (JudCon 2013)
 
Drools 6.0 (Red Hat Summit 2013)
Drools 6.0 (Red Hat Summit 2013)Drools 6.0 (Red Hat Summit 2013)
Drools 6.0 (Red Hat Summit 2013)
 

Recently uploaded

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Reducing the Cost of the Linear Growth Effect using Adaptive Rules with Unlinking and Lazy Rule Evaluation (ODBase 2018)

  • 1. Mark Proctor Chief Architect - Rules, BPM, Optimisation Red Hat Reducing the Cost of the Linear Growth Effect using Adaptive Rules with Unlinking and Lazy Rule Evaluation
  • 2. Introduction • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 3. The Problem • Acharya (Scaling up production system 1994) 3 areas: • Taming the combinatorial explosion • Improved memory subsystem performance • Eliminating linear average growth effect • Wasted work The Proposed Solution • Adaptive Rule Network via rule unlinking • Network sharing • Lazy rule evaluation • Isolated rules • Set Propagation • Batching of work Introduction
  • 4. Background Rete • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 5. Rete Classes Account long accountNo int balance CashFlow Date date int amount AccountPeriod Date start Date end
  • 6. Rete select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end acc.balance += cf.amount
  • 7. Rete select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end acc.balance += cf.amount
  • 8. Rete select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end acc.balance += cf.amount
  • 9. Rete select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end acc.balance += cf.amount
  • 10. Rete select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account() cf : CashFlow( type == CREDIT, accountNo == acc.accountNo, date >= ap.start && <= ap.end ) then acc.balance += cf.amount; end acc.balance += cf.amount
  • 11. Rete rule "Increase balance for AccountPeriod Credits"
 when
 ap : AccountPeriod( )
 acnt : Account( )
 cf : CashFlow( type == CashFlowType.CREDIT,
 accountNo == acnt.accountNo,
 date >= ap.start && <= ap.end )
 then
 modify(acnt) { balance = acnt.balance + cf.amount; }
 end rule "Decrease balance for AccountPeriod Debits"
 when
 ap : AccountPeriod( )
 acnt : Account( )
 cf : CashFlow( type == CashFlowType.DEBIT, accountNo == acnt.accountNo, date >= ap.start && <= ap.end )
 then
 modify(acnt) { balance = acnt.balance - cf.amount }
 end CashFlow date amount type accountNo 12-Jan-12 100 CREDIT 1 2-Feb-12 200 DEBIT 1 18-May-12 50 CREDIT 1 9-Mar-12 75 CREDIT 1 AccountingPeriod start end 01-JAN-2012 31-MAR-2012 Account accountNo balance 1 0 CashFlow date amount type accountNo 12-Jan-12 100 CREDIT 1 9-Mar-12 75 CREDIT 1 CashFlow date amount type accountNo 2-Feb-12 200 DEBIT 1 Account accountNo balance 1 -25
  • 12. Rete rule "Print balance for AccountPeriod" salience -50
 when
 ap : AccountPeriod()
 acnt : Account( )
 then
 System.out.println( "Account Number " + acnt.accountNo + " balance " + acnt.balance );
 end Agenda 1 increase balance arbitrary2 decrease balance 3 increase balance 4 print balance
  • 13. Rete Root Alpha Node Left Input Adapter Node Join Node Terminal Node Root Account Period Account Cashflow type == Credit type == Debit Credit DebitPrint LIA Alpha Network Beta Network Shared Network
  • 14. Background Related Research • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 15. • Treat (Miranker 1987) • Adaptive Networks • ’rule-active’ flag. • Linear time cost • Rete/UL (Doorenbos 1994) • left and right unlinking Related Research Root Account Period Account Cashflow type == Credit type == Debit Credit DebitPrint LIA Alpha Network Beta Network
  • 16. Solution Segmentation • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 17. • R1 = A B C • R2 = A D E • R3 = A B D E Segmentation A C R1 B B C D E A R1 R2 D E C A B R1 R3
  • 18. • R1 = A B C • R3 = A B D E • R4 = A B D F G Segmentation D E C A B R1 R3 F G R4
  • 19. • R1 = A not ( B not ( C ) ) D • R2 = A B C Segmentation A D R1 Not B Not C R2
  • 20. Solution Bitmask • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 21. • R1 = A B C • R2 = A D E Bitmask A C R1 B 1 2 4 1 B C D E A R1 R2 1 1 2 2 1 2 1 2 1
  • 22. • R1 = A B C • R3 = A B D E • R4 = A B D F G Bitmask D E C A B R1 R2 F G R3 1 2 4 1 2
  • 23. • R1 = A not ( B not ( C ) ) D • R2 = A B C Bitmask A D R1 Not B Not C C R2 1 2 4
  • 24. Solution Runtime • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 25. • 3 Levels of Memory • Beta • Segment • Rule Runtime Rule Memory Segment Memory Node Memory Node Memory Node Memory Segment Memory Node Memory Node Memory Node Memory Segment Memory Node Memory Node Memory Node Memory Segment Memory Node Memory Node Memory Node Memory Rule Memory Rule Memory Rule Memory
  • 26. • Linked rules are scheduled for evaluation • Lazy rule evaluation • Split Alpha and Beta network evaluation • Necessary to ensure all possible rules are scheduled, before evaluation happens. • Better batch evaluation • Set Propagation • Better batch evaluation • Eventual support for parallel joins and collection- oriented match (Tambe 1993) Runtime A D R1 Not B Not C C R2 1 2 4
  • 27. Benchmark Implementation • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 28. • Both algorithms share large amounts of code • discrimination tree, expression evaluations, tuple data structures. Lazy rules adds the propagation set around exist Tuple and alternative rule evaluation code. • Parameterised benchmarks • Segments and fan-out, nodes per segment and number of facts. • Number of facts was maxed at 32. • All rules generated with expressions so all join attempts match. • JMH Harness with suitable warmups and execution times. • 4 Benchmarks • Match And Fire All Rules • Repeat First Rule Fire • Repeat Last Rule Fire • Iterate And Fire All Rules Benchmark
  • 29. Conclusion Results • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 30. • Match And Fire All Rules. • Expected similar results, as no wasted 
 work. However lazy was twice as fast • and growing. • Conf 5 is 25.9% to 74.1% • Repeat First Rule Fire. • 3.8% to 96.2% for conf 5. • Can see Rete getting slower as more • rules added. GC also an impact. • Repeat Last Rule Fire. • Same as ^ • Iterate And Fire All Rules. • 16.7% to 83.3%. Set Propagation larger
 impact than expected. Results ms/op percentage stack ms/op ms/op ms/op percentage stack percentage stack percentage stack
  • 31. Conclusion Future work • Introduction • Background • Rete • Related Research • Solution • Segmentation • Bitmask • Runtime • Benchmark • Implementation • Conclusion • Results • Future Work
  • 32. • Alpha network unlinking, to have same advantages of Rete/UL on large fanouts. • Improved linking heuristics, such as arc consistency • Future Work