Skip to content

perf: improve performance of ConnectedRange collector#2473

Merged
triceo merged 2 commits into
TimefoldAI:mainfrom
triceo:connected
Jul 9, 2026
Merged

perf: improve performance of ConnectedRange collector#2473
triceo merged 2 commits into
TimefoldAI:mainfrom
triceo:connected

Conversation

@triceo

@triceo triceo commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This contains two separate commits:

  • First, it significantly improves the performance of the ConnectedRange collector based on the latest ESS dataset. This shows 50 % of CPU time was spent in range's hash code computations, and also a lot of memory was wasted allocating arrays.
  • Second, a move iterator bug was discovered during this session that should lead to faster solving overall.

Copilot AI review requested due to automatic review settings July 7, 2026 07:14
@triceo triceo requested a review from zepfred as a code owner July 7, 2026 07:14
@triceo

triceo commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Adding @Christopher-Chianelli to review the range work.
Also CC @LDWNS who can check how faster this is in practice. I wouldn't be surprised if it was 2x or more.

@triceo triceo added this to the v2.4.0 milestone Jul 7, 2026
@triceo triceo self-assigned this Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets solver runtime improvements by optimizing the connected-ranges collector (reducing hash/alloc overhead) and fixing an iterator staleness bug that can impact overall solving performance.

Changes:

  • Optimized connected-range hashing and reduced allocation overhead in connected-ranges internals.
  • Reworked join-node filtered update handling to avoid expensive scans by introducing versioned “mark” support in TupleList.
  • Added/updated tests to cover incremental join updates and connected-range hash-code behavior; added a focused test for UnindexedJoinBiNode update semantics.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/src/test/java/ai/timefold/solver/core/impl/score/stream/common/bi/AbstractBiConstraintStreamTest.java Adds incremental-update regression tests for joins with filtering and unchanged keys.
core/src/test/java/ai/timefold/solver/core/impl/score/stream/collector/connected_ranges/ConnectedRangeTrackerTest.java Refactors test code and adds hashCode/equals consistency and mutation coverage.
core/src/test/java/ai/timefold/solver/core/impl/bavet/bi/UnindexedJoinBiNodeTest.java New unit tests asserting left/right update refresh behavior in unindexed joins.
core/src/main/java/ai/timefold/solver/core/impl/score/stream/collector/connected_ranges/RangeSplitPoint.java Tweaks split-point internal data structures and iterator to improve performance.
core/src/main/java/ai/timefold/solver/core/impl/score/stream/collector/connected_ranges/ConnectedRangeImpl.java Introduces cached hashCode and reorders equality checks for performance.
core/src/main/java/ai/timefold/solver/core/impl/score/stream/collector/connected_ranges/ConnectedRangeChainImpl.java Excludes splitPointSet from hashCode to avoid expensive hashing.
core/src/main/java/ai/timefold/solver/core/impl/heuristic/selector/move/composite/BiasedRandomUnionMoveIterator.java Fixes stale-refresh behavior to avoid unnecessary rebuilds and ensure correctness.
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/tuple/TupleList.java Adds versioned mark/getMark to support faster join-node updates.
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/AbstractJoinNode.java Uses versioned marks to avoid scanning partner lists during filtered updates; refactors retract/update helpers.

Copilot AI review requested due to automatic review settings July 7, 2026 07:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 7, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@Christopher-Chianelli Christopher-Chianelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; can probably simplify the hashCode/equals even more.

Copilot AI review requested due to automatic review settings July 9, 2026 09:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 9, 2026 09:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@triceo triceo merged commit 8cdd583 into TimefoldAI:main Jul 9, 2026
23 of 24 checks passed
@triceo triceo deleted the connected branch July 9, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants