tkobayas commented on PR #6089:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6089#issuecomment-2357972303

   Hi @mariofusco 
   
   The performance issue only arises when a KieProject has many kbase models 
and many large spreadsheets.
   
   In this case, `AbstractKieProject.buildKnowledgePackages` is called per 
kbase model. `AbstractKieProject.buildKnowledgePackages` calls 
`AbstractKieProject.addFiles` -> `KieBuilderImpl.filterFileInKBase` -> 
`KieBuilderImpl.filterFileInKBase` -> `KieBuilderImpl.isFileInKieBase` -> 
`KieBuilderImpl.packageNameForFile` -> `KieBuilderImpl.packageNameFromAsset` -> 
`KieBuilderImpl.packageNameFromDtable` -> 
`DecisionTableProviderImpl.loadFromResource` -> `SpreadsheetCompiler.compile`.
   
   If a KieProject has 20 kbase models and 20 spreadsheets, 
`packageNameFromDtable` is called 400 times. One `packageNameFromDtable`  may 
not take very long time (1 or 2 seconds), but 400 times are significant.
   
   
https://github.com/apache/incubator-kie-drools/blob/main/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieBuilderImpl.java#L438
   
   This PR introduces `packageNameCache` and brings the cache across static 
methods. This doesn't look nice, but firstly I wanted to share the idea.
   
   Another possible approach would be caching the DRL generated by 
SpreadsheetCompiler, but where is the appropriate place to have the cache? (and 
when we should invalidate the cache)
   
   ---
   
   Workaround for non-fixed version: Split KieContainer/ReleaseId per 
kbaseModel so you can avoid the combinatorial explosion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to