Skip to content

[CELEBORN-2395] Reduce allocations in Utils.split* methods - #3771

Closed
yew1eb wants to merge 1 commit into
apache:mainfrom
yew1eb:CELEBORN-2395
Closed

[CELEBORN-2395] Reduce allocations in Utils.split* methods#3771
yew1eb wants to merge 1 commit into
apache:mainfrom
yew1eb:CELEBORN-2395

Conversation

@yew1eb

@yew1eb yew1eb commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Rewrite the three String.split("-")-based key splitters in Utils to locate the - separator once and slice with substring, instead of regex-splitting and rejoining:

  • splitShuffleKeylastIndexOf('-') + two substring calls
  • splitPartitionLocationUniqueIdlastIndexOf('-') + two substring calls
  • splitAttemptKeyindexOf('-') + two substring calls

This removes the regex compilation, the intermediate String[], the dropRight(1) array copy, and the StringBuilder + new String from mkString.

Why are the changes needed?

splitShuffleKey is on the per-push-message hot path, called from both recordAppActiveConnection (default-on per-app metrics) and checkAuth. A production async-profiler CPU flame graph on celeborn-worker (80,611 samples; true stack-reconstruction, self sum = 100%) shows the frame's self cost is near zero, but its inclusive cost is ~4.23%, of which ~2.95% comes through the default-on recordAppActiveConnection path and ~1.27% through the always-on checkAuth path.

image image

The allocation reduction also lowers young-GC pressure under high push QPS.

Does this PR resolve a correctness bug?

No

Does this PR introduce any user-facing change?

No

How was this patch tested?

  • Added unit tests in UtilsSuite covering splitShuffleKey (including applicationId containing -, plus a makeShuffleKey round-trip), splitPartitionLocationUniqueId, and splitAttemptKey.
  • ./build/mvn -pl common -Dtest=UtilsSuite test — all split* tests pass. (Two unrelated CelebornConfSuite failures — Fallback to parent module's config... and rpc_service and rpc_client... — are pre-existing on a clean upstream/main; verified by stashing this change and re-running.)
  • ./build/mvn -pl common spotless:check — clean.

@yew1eb yew1eb changed the title [CELEBORN-2395] Reduce allocations in Utils.split* methods on worker hot path [CELEBORN-2395] Reduce allocations in Utils.split* methods Jul 28, 2026
yew1eb added a commit to yew1eb/celeborn that referenced this pull request Jul 28, 2026

@SteNicholas SteNicholas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

SteNicholas pushed a commit that referenced this pull request Aug 3, 2026
## What changes were proposed in this pull request?

Rewrite the three `String.split("-")`-based key splitters in `Utils` to locate the `-` separator once and slice with `substring`, instead of regex-splitting and rejoining:

- `splitShuffleKey` → `lastIndexOf('-')` + two `substring` calls
- `splitPartitionLocationUniqueId` → `lastIndexOf('-')` + two `substring` calls
- `splitAttemptKey` → `indexOf('-')` + two `substring` calls

This removes the regex compilation, the intermediate `String[]`, the `dropRight(1)` array copy, and the `StringBuilder` + new `String` from `mkString`.

## Why are the changes needed?

`splitShuffleKey` is on the per-push-message hot path, called from both `recordAppActiveConnection` (default-on per-app metrics) and `checkAuth`. A production async-profiler CPU flame graph on `celeborn-worker` (80,611 samples; true stack-reconstruction, self sum = 100%) shows the frame's self cost is near zero, but its inclusive cost is ~4.23%, of which ~2.95% comes through the default-on `recordAppActiveConnection` path and ~1.27% through the always-on `checkAuth` path.

<img width="1619" height="260" alt="image" src="https://github.com/user-attachments/assets/6a807653-fcdd-4037-8d16-117ebe70046e" />

<img width="1686" height="244" alt="image" src="https://github.com/user-attachments/assets/240be695-4985-4f8a-abc1-e32c21c6d0ee" />

The allocation reduction also lowers young-GC pressure under high push QPS.

## Does this PR resolve a correctness bug?

 No

## Does this PR introduce any user-facing change?

 No

## How was this patch tested?

- Added unit tests in `UtilsSuite` covering `splitShuffleKey` (including `applicationId` containing `-`, plus a `makeShuffleKey` round-trip), `splitPartitionLocationUniqueId`, and `splitAttemptKey`.
- `./build/mvn -pl common -Dtest=UtilsSuite test` — all `split*` tests pass. (Two unrelated `CelebornConfSuite` failures — `Fallback to parent module's config...` and `rpc_service and rpc_client...` — are pre-existing on a clean `upstream/main`; verified by stashing this change and re-running.)
- `./build/mvn -pl common spotless:check` — clean.

Closes #3771 from yew1eb/CELEBORN-2395.

Authored-by: yew1eb <yew1eb@gmail.com>
Signed-off-by: Nicholas Jiang <programgeek@163.com>
@SteNicholas

Copy link
Copy Markdown
Member

Thanks. Merged to main(v1.0.0) and branch-0.7(v0.7.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants