apache/incubator-kie-drools

Investigate memory usage for KieModule / KieBase build

Opened this issue · 0 comments

50000 rules (a 53MB file) resulted in 3.7GB with Drools 8.44.0.Final with non-exec-model.

Executable model required more memory at the build time.

https://github.com/tkobayas/drools-heap-check
https://github.com/tkobayas/drools-heap-check-kjar

To be updated with more detailed data

Drools 8.44.0.Final

non-exec-model

KieFileSystem

5000 rules (a 5MB file)
after build -> 309 MB
after getKieBase -> 405 MB heap

  • org.drools.mvel.MVELConstraint : 205000 objects, 238MB retained heap
    • compilationUnit is not shared between the same expression constraint. Not sure if there is a room to improve.
    • evaluationContext takes some heap. In drools 7.62+, setting system property drools.evaluationContext.maxRuleDefs = 0 may reduce some heap.
  • org.drools.compiler.kie.builder.impl.MemoryKieModule : 1 object, 44MB retained heap
    • held by KieContainer, so there is not much to do

exec-model

KieFileSystem

500 rules ( a 5MB file)
after build -> 304 MB
after getKiebase -> 334 MB
almost 10 times larger than non-exec-model

  • org.drools.model.codegen.execmodel.PackageModel : 214MB

    • retains many javaparser objects (e.g. MethodDeclaration). Can we free them after build?
  • PredicateInformation takes non-negligible amount of heap. drools.predicateInformation.maxRuleDefs = 0 may reduce some heap. We may consider an option to completely disable PredicateInformation.

kjar

500 rules ( a 5MB file)
after build a kjar with kie-maven-plugin -> With VisualVM, footprint is around 420MB (code gen) and 970MB (compile)
after getKiebase with kjar client -> 69 MB (much smaller than KieFileSystem, but still larger than non-exec-model?)

5000 rules ( a 53MB file)
after build a kjar with kie-maven-plugin -> With VisualVM, footprint is around 3.7GB (code gen) and 11.8GB (compile)
after getKiebase with kjar client -> 485 MB (still larger than non-exec-model)

This GH issue is to investigate the memory usage and look for improvements.