Skip to content

perf: avoid boxing in externalized list var cases#2420

Merged
triceo merged 1 commit into
TimefoldAI:mainfrom
triceo:int
Jun 25, 2026
Merged

perf: avoid boxing in externalized list var cases#2420
triceo merged 1 commit into
TimefoldAI:mainfrom
triceo:int

Conversation

@triceo

@triceo triceo commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

6-7 % in CVRP profiling.

Copilot AI review requested due to automatic review settings June 25, 2026 10:47
@triceo triceo added this to the v2.3.0 milestone Jun 25, 2026
@triceo triceo self-assigned this Jun 25, 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 optimizes list-variable index lookups by avoiding boxing when index shadow variables are externalized, changing index access from nullable Integer to primitive int with -1 as the “unassigned” sentinel.

Changes:

  • Changed ListVariableStateSupply#getIndex(...) from @Nullable Integer to int (using -1 for unassigned) and updated helpers accordingly.
  • Updated delegating/index lookup plumbing to use ToIntFunction to avoid boxing.
  • Adjusted relevant test wiring to the new functional type.

Reviewed changes

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

Show a summary per file
File Description
core/src/test/java/ai/timefold/solver/core/impl/heuristic/selector/move/generic/list/kopt/KOptUtilsTest.java Updates test helper to use the new DelegatingListVariableStateSupply signature without boxing.
core/src/main/java/ai/timefold/solver/core/impl/heuristic/selector/move/generic/list/kopt/DelegatingListVariableStateSupply.java Switches index function to ToIntFunction to avoid boxing in K-opt utilities.
core/src/main/java/ai/timefold/solver/core/impl/domain/variable/ListVariableStateSupply.java Changes index API to primitive int and documents -1 as the unassigned sentinel.
core/src/main/java/ai/timefold/solver/core/impl/domain/variable/ListVariableState.java Propagates the -1 sentinel internally and adapts null-handling for externalized index storage.
core/src/main/java/ai/timefold/solver/core/impl/domain/variable/ExternalizedListVariableStateSupply.java Updates implementation to match the new primitive getIndex contract.

Copilot AI review requested due to automatic review settings June 25, 2026 11:15

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.

Did we not check if index == null anywhere in this code base when accessing a listVariableState? Changes LGTM, but it seems a bit small.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
65.6% Coverage on New Code (required ≥ 70%)

See analysis details on SonarQube Cloud

@triceo triceo merged commit 9aee73c into TimefoldAI:main Jun 25, 2026
20 of 24 checks passed
@triceo triceo deleted the int branch June 25, 2026 14:44
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