Skip to content

Conversation

@yew1eb
Copy link
Contributor

@yew1eb yew1eb commented Jan 19, 2026

What changes were proposed in this pull request?

Add shuffleIdLocks (fine-grained locks per shuffleId), replace global shuffleMapperAttempts lock in initMapperAttempts and finishMapperAttempt.

Why are the changes needed?

High concurrency causes lock contention on shuffleMapperAttempts in finishMapperAttempt, leading to abnormally long shuffle write time for small queries in Kyuubi Shared Mode. Fine-grained locks eliminate cross-shuffle blocking and improve concurrency.

Does this PR resolve a correctness bug?

No.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

CI.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses lock contention issues in ReducePartitionCommitHandler.finishMapperAttempt by introducing fine-grained per-shuffle locks. The change replaces synchronization on the global shuffleMapperAttempts object with per-shuffle lock objects stored in a new shuffleIdLocks ConcurrentHashMap.

Changes:

  • Added shuffleIdLocks ConcurrentHashMap to store per-shuffle lock objects
  • Updated finishMapperAttempt to acquire per-shuffle locks instead of global lock
  • Updated initMapperAttempts to acquire per-shuffle locks instead of global lock

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

private val shuffleMapperAttempts = JavaUtils.newConcurrentHashMap[Int, Array[Int]]()
// TODO: Move this to native Int -> Int Map
private val shuffleToCompletedMappers = JavaUtils.newConcurrentHashMap[Int, Int]()
private val shuffleIdLocks = JavaUtils.newConcurrentHashMap[Int, Object]()
Copy link
Contributor

Choose a reason for hiding this comment

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

Better remove the lock object when the shuffle expired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. PTAL

…ndler.finishMapperAttempt via fine-grained locks
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.

2 participants