You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@celeborn.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2023/06/08 06:08:30 UTC
[GitHub] [incubator-celeborn] pan3793 commented on a diff in pull request #1560: [CELEBORN-648][SPARK] Improve pref SendBufferPool and logs about memory
pan3793 commented on code in PR #1560:
URL: https://github.com/apache/incubator-celeborn/pull/1560#discussion_r1222500077
##########
client-spark/common/src/main/java/org/apache/spark/shuffle/celeborn/SendBufferPool.java:
##########
@@ -36,23 +37,23 @@ public static SendBufferPool get(int capacity) {
private final int capacity;
// numPartitions -> buffers
- private LinkedList<byte[][]> buffers;
+ private final LinkedList<byte[][]> buffers;
public SendBufferPool(int capacity) {
this.capacity = capacity;
buffers = new LinkedList<>();
}
public synchronized byte[][] acquireBuffer(int numPartitions) {
- for (int i = 0; i < buffers.size(); i++) {
- if (buffers.get(i).length == numPartitions) {
- return buffers.remove(i);
+ Iterator<byte[][]> iterator = buffers.iterator();
+ while (iterator.hasNext()) {
+ byte[][] candidate = iterator.next();
+ if (candidate.length == numPartitions) {
+ iterator.remove();
+ return candidate;
}
}
- if (buffers.size() == capacity) {
- buffers.removeFirst();
Review Comment:
what's the benefit of shrink buffer during acquire? it should be ok to do it only in return
--
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: issues-unsubscribe@celeborn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org