Skip to content

Optimize string concatenation in NodeSelectionInvocationHandler.getNodeDescription() #3262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

ori0o0p
Copy link
Contributor

@ori0o0p ori0o0p commented Apr 18, 2025

Replace String.join with Collectors.joining to avoid intermediate collection creation, improving performance by eliminating the unnecessary List creation step.

Make sure that:

This optimization changes the getNodeDescription() method to use the more efficient Stream collector pattern, which directly collects stream elements into a joined string rather than first collecting to an intermediate list. While the functional outcome remains identical, this approach avoids the unnecessary memory allocation of the temporary list collection, resulting in improved performance especially in high-throughput scenarios.

The existing test suite confirms that the behavior remains consistent with the previous implementation.

Related Issue

Closes #3261

Replace String.join with Collectors.joining to avoid intermediate collection creation,
improving performance by eliminating the unnecessary List creation step.
@ori0o0p ori0o0p changed the title Optimize string concatenation in getNodeDescription() Optimize string concatenation in NodeSelectionInvocationHandler.getNodeDescription() Apr 18, 2025
Copy link
Collaborator

@tishun tishun left a comment

Choose a reason for hiding this comment

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

LGTM

@tishun tishun merged commit 5087808 into redis:main Apr 23, 2025
7 checks passed
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.

Performance Optimization: Replace String.join with Collectors.joining in NodeSelectionInvocationHandler.getNodeDescription
2 participants