Optaplanner-升级到8后,SolverFactory创建大大减慢了
我最近将Optaplanner升级到8,但是我注意到SolverFactory的创建减慢了很多,过去在我的本地机器上花费了约200ms,但现在需要4000+MS。这也发生在服务器端(速度慢了80%)。在我们的用例中,经常创建求解功能(用于不同的输入),因此这确实会影响性能。
更具体地说,此方法调用变慢得多:
SolverFactory<Solution_> solverFactory = SolverFactory.create(solverConfig);
我也尝试了
SolverFactory<Solution_> solverFactory = SolverFactory.createFromXmlResource(someXmlFile);
同一时间,并且比Optaplanner 7慢。(在7中,我使用solverFactory.Createfactory.CreateFromxmlResource(so soxmlfile)
)我可以加快速度吗?
更多信息:
我使用的是optaplanner 8.22.0. -final带有得分DRL,我设置了评分的方式,只是
solverConfig.getScoreDirectorFactoryConfig().setScoreDrlFileList(drlFileList);
我们用来使用kiebase在7 btw中设置了评分。
I recently upgraded Optaplanner to 8, however I noticed that solverFactory creation slowed down by a lot, used to take around 200ms on my local machine, but now it's taking 4000+ms. This also happens on the server side too (almost 80% slower). In our use case, the solverFactory is frequently created (for different input) so this is really impacting the performance.
More specifically, this method call became a lot slower:
SolverFactory<Solution_> solverFactory = SolverFactory.create(solverConfig);
I also tried
SolverFactory<Solution_> solverFactory = SolverFactory.createFromXmlResource(someXmlFile);
Both take around the same time and it's way slower than Optaplanner 7. (In 7 I used SolverFactory.createFromXmlResource(someXmlFile)
)
Is there some way I could speed it up?
Some more information:
I'm using Optaplanner 8.22.0.Final with Score DRL, the way I set scoreDrl is just
solverConfig.getScoreDirectorFactoryConfig().setScoreDrlFileList(drlFileList);
We used to use kieBase to set scoreDrl in 7 btw.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从火焰图中看来,罪魁祸首是drools alpha网络汇编。在约束流或DRL中,ANC可帮助您以一次性启动成本为代价获得运行时性能的50%。 (该费用发生在
solverFactory
创建。该数字反映了我们在内部基准测试中看到的内容,YMMV。)如果您愿意,可以在求解器配置中禁用ANC,但我不会。另一个选择是使用Quarkus,这可能会将这项工作转移到建立时间,从而使您在运行时不支付任何汇编罚款;但是,这仅适用于CS,得分DRL不支持它。
如果您使用的是程序化求解器配置,则此是您需要致电禁用ANC的方法。或者,在XML求解器配置中:
From the flame graph, it appears that the culprit is Drools alpha network compilation. In constraint streams or DRL, ANC helps you get ~50 % increase in runtime performance, at the expense of one-time startup cost. (That cost happens at
SolverFactory
creation. The number reflects what we've seen in internal benchmarks, YMMV.)ANC can be disabled in the solver config if you prefer, but I wouldn't. Another option would be to use Quarkus, which may move this work to build-time, allowing you to pay no compilation penalty at run-time; this only applies to CS though, score DRL does not support it.
If you're using programmatic solver configuration, this is the method you need to call to disable ANC. Alternatively in XML solver config: