Skip to content

Conversation

@lesnik2u
Copy link

What is the issue

https://github.com/riptano/cndb/issues/15990

What does this PR fix and why was it fixed

  • What: Eliminates unnecessary array allocations in PathUtils.atomicMoveWithFallback() by pre-allocating CopyOption[] arrays as static constants.

  • Why: JFR profiling showed this method was a memory allocation hotspot during RemoteFileCache preloading. Each call to Files.move() with varargs parameters created new arrays, causing excessive GC pressure.

@lesnik2u lesnik2u self-assigned this Nov 13, 2025
@github-actions
Copy link

github-actions bot commented Nov 13, 2025

Checklist before you submit for review

  • This PR adheres to the Definition of Done
  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits
  • All new files should contain the DataStax copyright header instead of the Apache License one

@lesnik2u lesnik2u marked this pull request as ready for review November 13, 2025 21:30
Copy link

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Patch is missing unit tests

are there already unit tests that covers the methods you are changing ?

try
{
Files.copy(from, to, option);
Files.copy(from, to, new CopyOption[] { option });

Choose a reason for hiding this comment

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

we still allocate a new array here ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes there already are unit tests that cover the methods I've changed. https://github.com/datastax/cassandra/blob/main/test/unit/org/apache/cassandra/io/util/PathUtilsTest.java

Fixed the unnecessary alocation.

Copy link

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

@cassci-bot
Copy link

✔️ Build ds-cassandra-pr-gate/PR-2124 approved by Butler


Approved by Butler
See build details here

@lesnik2u lesnik2u merged commit 3d62e03 into main Nov 19, 2025
498 checks passed
@lesnik2u lesnik2u deleted the CNDB-15990 branch November 19, 2025 12:52
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.

4 participants