我正在Linux(开放式嵌入式)盒(单核600MHz,512MB RAM,Java SE Embedded 1.8)上运行Drools 7.10.0-FINAL Fusion,并在寻找可以改善Drools启动时间的方法。现在大约是32秒,将其减半是很好的。
我使用kie-maven-plugin作为mvn clean install -DgenerateModel=YES -e
构建的kjar模块中有一个包含两个简单规则的.drl文件。
开始会话为
1 KieServices ks = KieServices.Factory.get();
2 //this is slower KieContainer kContainer = ks.getKieClasspathContainer();
3 ReleaseId releaseId = ks.newReleaseId("...", "KnowledgeBase", "1.0");
4 KieContainer kContainer = ks.newKieContainer(releaseId);
5 this.kieSession1 = kContainer.newKieSession();
我得到的时间
1 06:11:06,141 INFO (ServiceDiscoveryImpl.java:107) Loading kie.conf from jar:!/META-INF/kie.conf in classloader sun.misc.Launcher$AppClassLoader@387f44
2 06:11:06,591 INFO (ServiceDiscoveryImpl.java:141) Adding Service org.drools.compiler.kie.builder.impl.KieServicesImpl
3 06:11:06,890 INFO (ServiceDiscoveryImpl.java:141) Adding Service org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl
4 06:11:06,969 INFO (ServiceDiscoveryImpl.java:141) Adding Service org.drools.core.io.impl.ResourceFactoryServiceImpl
5 06:11:07,065 INFO (ServiceDiscoveryImpl.java:141) Adding Service org.drools.core.marshalling.impl.MarshallerProviderImpl
6 06:11:07,120 INFO (ServiceDiscoveryImpl.java:141) Adding Service org.drools.core.concurrent.ExecutorProviderImpl
7 06:11:07,140 INFO (ServiceDiscoveryImpl.java:107) Loading kie.conf from jar:drools-model-compiler-7.10.0.Final.jar!/META-INF/kie.conf in classloader sun.misc.Launcher$AppClassLoader@387f44
8 06:11:07,280 INFO (ServiceDiscoveryImpl.java:141) Adding Service org.drools.modelcompiler.CanonicalKieModuleProvider
9 06:11:07,452 DEBUG (KieRepositoryImpl.java:89) Cannot load a KieRepositoryScanner, using the DummyKieScanner
10 06:11:07,489 DEBUG (KieRepositoryImpl.java:130) KieModule Lookup. ReleaseId KnowledgeBase:1.0 was not in cache, checking classpath
11 06:11:07,522 INFO (KieRepositoryImpl.java:184) Adding KieModule from classpath: file:KnowledgeBase-1.0.jar
12 06:11:07,788 DEBUG (ClasspathKieProject.java:397) KieModule URL type=jar url=KnowledgeBase-1.0.jar
13 06:11:20,511 DEBUG (ClasspathKieProject.java:265) Found and used pom.properties META-INF/maven/.../KnowledgeBase/pom.properties
14 06:11:38,421 INFO (RuleEngineModule.java:95) KieSession started
大部分时间(日志条目7-13)用在KieContainer kContainer = ks.newKieContainer(releaseId);
任何已知技术或有根据的猜测如何加快kie容器实例化?