Repository navigation
chore: improve initialization perfomance - #2856
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
I have not reviewed the PR yet, will do that next week. But I have some notes based on the description:
Out-of-range assigned values are a bug. If we can no longer report that bug to users, then the performance optimization has gone too far.
The count must never be incorrect. Which is why we first build the ranges - so that the count will always match reality. I do not like the consequences of these changes. How much performance are we really gaining in exchange? Considering we have not seen complaints about solver cold start performance, I am not in favor of introducing these behavior changes. |
I added a flag to the score director to control when we validate the value range. This is still a draft, and I'm checking whether we can skip validation in certain scenarios without causing an inconsistent state. The results show that the enrichment process decreased from 21 seconds to 6 seconds in my local tests, and Marek was able to reproduce these results as well. |
bde092c to
83dbb70
Compare
83dbb70 to
aa495c2
Compare
aa495c2 to
ed1b189
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
3b0d48c to
4693ab6
Compare
triceo
left a comment
There was a problem hiding this comment.
- Some of my comments were marked as resolved, but not actually resolved.
- The validation code in
AbstractScoreDirectorneeds to be refactored to handle a single concept in a single place. - Github is showing me Git conflicts, although I'm not exactly sure why.
…rs and list variable reset
…on errors and list variable reset
…n errors and list variable reset
eb7fe5e to
a7e9e10
Compare
Several places built, deduplicated and validated full value ranges when all they needed was a count. On large datasets, especially when entities have their own value ranges, that made setup and solution updates slower than necessary. This PR reads sizes directly where it safely can, and builds value ranges only when the values themselves are needed.
Changes
Entities that share the same value range instance (for example, one list of all values) are expanded into the composite value range only once.
The problem size statistics read the size of each entity's value range directly from the provider, calling it once per entity.
Counting runs the same cheap checks as building: null value range, null first or last element, and a
Setwith undefined iteration order or a null element.Value ranges from the solution are still built, deduplicated and cached when counted, because the list variable state needs them anyway.
A new score director builder option,
withAssertValueRange, is on by default, independently of lookup; the solver always validates.It is off where the solution is already validated or nothing relies on it:
move thread score directors (they work on a clone of a validated solution), redundant score-from-scratch assertions,
and shadow-variable-only updates (
SolutionManager.update(solution, UPDATE_SHADOW_VARIABLES_ONLY)andSolutionManager.updateShadowVariables(solution)), documented in the upgrade recipe.Even without validation,
setWorkingSolutionstill fails when the lists hold more values than the value range, naming the value outside of it, or reporting a value assigned more than once.It also still detects a null
@ProblemFactCollectionProperty.They are no longer computed in
setWorkingSolution, and the value count and the problem scale are computed in a single pass over the entities.For a list variable, the number of unassigned values now comes from the list variable state in O(1),
instead of a pass over all entities at every Construction Heuristic start, including the nested one in every Ruin&Recreate move.
Fixes