mridulm commented on code in PR #2462:
URL: https://github.com/apache/celeborn/pull/2462#discussion_r1568245018
##########
client/src/main/scala/org/apache/celeborn/client/ChangePartitionManager.scala:
##########
@@ -151,7 +156,7 @@ class ChangePartitionManager(
oldPartition,
cause)
- requests.synchronized {
+ locks(partitionId % locks.length).synchronized {
if (requests.containsKey(partitionId)) {
requests.get(partitionId).add(changePartition)
logTrace(s"[handleRequestPartitionLocation] For $shuffleId, request
for same partition" +
Review Comment:
The original code is doing the same.
If partition exists, it will add to the set - else create new and add with
the entry.
(Removing other parts of the code, it is essentially)
```
if (requests.containsKey(partitionId)) {
requests.get(partitionId).add(changePartition)
} else {
// an early exit condition
val set = new util.HashSet[ChangePartitionRequest]()
set.add(changePartition)
requests.put(partitionId, set)
}
```
It is probing the map multiple times though, which is something we can avoid.
(the `return` in the ` getLatestPartition` case I suggested looks wrong
though - we should return `null` and exit if `set` is `null`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]