Reputation: 23
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.
Upvotes: 1
Views: 119
Reputation: 5702
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:
....
<scoreDirectorFactory>
<scoreDrl>...</scoreDrl>
<droolsAlphaNetworkCompilationEnabled>false</droolsAlphaNetworkCompilationEnabled>
...
</scoreDirectorFactory>
...
Upvotes: 1