perf: improve runtime performance of exhaustive search#2214
Open
triceo wants to merge 4 commits intoTimefoldAI:mainfrom
Open
perf: improve runtime performance of exhaustive search#2214triceo wants to merge 4 commits intoTimefoldAI:mainfrom
triceo wants to merge 4 commits intoTimefoldAI:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes exhaustive search runtime by reducing per-step allocations and stream overhead, and by simplifying several hot-path code paths involved in node expansion, undo handling, and destination selection.
Changes:
- Replace stream-based iteration in list destination selection with lightweight iterator implementations (
MappingIterator,ConcatenatingIterator). - Reduce allocation/copying on the undo hot path by returning an undo
Movefrom the recording score director and resetting the internal change list by reference swap. - Micro-optimize exhaustive search internals (comparators, queue operations, remove unused expandable tracking).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/ai/timefold/solver/core/impl/score/director/RevertableScoreDirector.java | Replaces copyChanges() with createUndoMove() and updates contract/Javadoc. |
| core/src/main/java/ai/timefold/solver/core/impl/move/VariableChangeRecordingScoreDirector.java | Implements createUndoMove() without copying and swaps the change list on undo. |
| core/src/main/java/ai/timefold/solver/core/impl/move/EphemeralMoveDirector.java | Switches to the new createUndoMove() API. |
| core/src/main/java/ai/timefold/solver/core/impl/heuristic/selector/list/ElementDestinationSelector.java | Removes stream usage in iterators and switches to new iterator utilities. |
| core/src/main/java/ai/timefold/solver/core/impl/heuristic/selector/common/iterator/MappingIterator.java | Adds a minimal mapping iterator to avoid stream overhead. |
| core/src/main/java/ai/timefold/solver/core/impl/heuristic/selector/common/iterator/ConcatenatingIterator.java | Adds a concatenating iterator to avoid stream concatenation overhead. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/scope/ExhaustiveSearchPhaseScope.java | Removes unused depth/expandable tracking and simplifies expandable node addition. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/node/comparator/ScoreFirstNodeComparator.java | Simplifies comparator logic to reduce branching. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/node/comparator/OriginalOrderNodeComparator.java | Simplifies comparator logic to reduce branching. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/node/comparator/OptimisticBoundFirstNodeComparator.java | Simplifies comparator logic to reduce branching. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/node/comparator/DepthFirstNodeComparator.java | Simplifies comparator logic to reduce branching. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/node/comparator/BreadthFirstNodeComparator.java | Simplifies comparator logic to reduce branching. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/node/ExhaustiveSearchNode.java | Removes unused expandable field/accessors. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/decider/AbstractExhaustiveSearchDecider.java | Removes expandable logging and uses getFirst() for layer access. |
| core/src/main/java/ai/timefold/solver/core/impl/exhaustivesearch/DefaultExhaustiveSearchPhase.java | Uses removeLast() to pop the next node more directly. |
core/src/main/java/ai/timefold/solver/core/impl/move/VariableChangeRecordingScoreDirector.java
Show resolved
Hide resolved
...in/java/ai/timefold/solver/core/impl/heuristic/selector/list/ElementDestinationSelector.java
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.