perf: further improve performance of ElementAwareArrayList#2373
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues performance-focused work by optimizing ElementAwareArrayList internals (gap tracking/compaction and backing-array retention), refining tabu acceptor behavior (including deterministic fading-taboo decisions), and simplifying Bavet leaf indexing by removing the linked-list backend.
Changes:
- Reworked
ElementAwareArrayListto avoid fail-fast iteration/modCount overhead, addcompact()+firstGapPositionfast paths, and free large backing arrays when the list becomes empty. - Updated tabu acceptors to use a new fading-taboo decision path with deterministic random consumption behavior; tightened configuration validation and tabu size constraints.
- Removed
LinkedListLeafIndexerand switched indexer construction/tests toRandomAccessLeafIndexer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/ai/timefold/solver/core/impl/util/ElementAwareArrayList.java | Optimizes gap handling/compaction, iterator behavior, and backing array retention/freeing. |
| core/src/test/java/ai/timefold/solver/core/impl/util/ElementAwareArrayListTest.java | Adds tests for compaction/first-gap behavior and backing-array free-path; adds randomized stress test. |
| core/src/main/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/AbstractTabuAcceptor.java | Refactors fading-taboo acceptance into a decision helper that can avoid consuming random in certain outcomes. |
| core/src/main/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/size/FixedTabuSizeStrategy.java | Enforces tabu size must be at least 1 and improves exception message. |
| core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/size/FixedTabuSizeStrategyTest.java | Adds test coverage for invalid tabu sizes (0 and negative). |
| core/src/main/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/AcceptorFactory.java | Improves error messages, validates tabu acceptor configs, and removes duplicated configuration code. |
| core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/AcceptorFactoryTest.java | Verifies factory rejects tabu acceptors without configured sizes. |
| core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/ValueTabuAcceptorTest.java | Adds fading-taboo behavior test using deterministic TestRandom. |
| core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/EntityTabuAcceptorTest.java | Adds fading-taboo behavior test using deterministic TestRandom. |
| core/src/test/java/ai/timefold/solver/core/impl/localsearch/decider/acceptor/tabu/MoveTabuAcceptorTest.java | Introduces move-taboo tests, including fading-taboo and aspiration scenarios. |
| core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/LinkedListLeafIndexer.java | Removed linked-list leaf backend implementation. |
| core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/LeafIndexer.java | Updates sealed permits to remove the deleted linked-list backend. |
| core/src/main/java/ai/timefold/solver/core/impl/bavet/common/index/IndexerFactory.java | Switches indexer backend creation to always use RandomAccessLeafIndexer. |
| core/src/test/java/ai/timefold/solver/core/impl/bavet/common/index/FusedEqualIndexTest.java | Updates fused equal index test to use RandomAccessLeafIndexer. |
zepfred
reviewed
Jun 15, 2026
zepfred
reviewed
Jun 15, 2026
zepfred
reviewed
Jun 15, 2026
zepfred
reviewed
Jun 15, 2026
zepfred
reviewed
Jun 15, 2026
zepfred
reviewed
Jun 15, 2026
zepfred
reviewed
Jun 15, 2026
zepfred
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. I have a few minor comments and some questions.
This reverts commit 9ba4ff6.
|
zepfred
approved these changes
Jun 19, 2026
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.



The goal here is to minimize the overhead of add/remove methods, as they showed up the highest in profiling in comparison to the original ElementAwareLinkedList.