SteNicholas commented on code in PR #3825:
URL: https://github.com/apache/celeborn/pull/3825#discussion_r3845087192


##########
common/src/test/java/org/apache/celeborn/common/protocol/PartitionLocationMemorySuiteJ.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.common.protocol;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("Manual JOL benchmark; run main to print retained-size comparisons.")
+public class PartitionLocationMemorySuiteJ {
+
+  private static final int ENDPOINT_COUNT = 2000;
+
+  public static void main(String[] args) throws Exception {
+    int pairCount = args.length > 0 && "largePeer".equals(args[0]) ? 1_000_000 
: 10_000;
+    new PartitionLocationMemorySuiteJ().printPeerPairFootprint(pairCount, 
ENDPOINT_COUNT);
+  }
+
+  @Test
+  public void printPartitionLocationFootprint() throws Exception {
+    printPeerPairFootprint(10_000, ENDPOINT_COUNT);
+  }
+
+  private void printPeerPairFootprint(int pairCount, int endpointCount) throws 
Exception {
+    compare(
+        loadGraphLayout(),
+        pairCount + " partition peer pairs across " + endpointCount + " 
endpoints",
+        newOldLocationPairArray(pairCount, endpointCount),
+        newLocationPairArray(pairCount, endpointCount));
+  }
+
+  private PartitionLocation[] newLocationPairArray(int size, int 
endpointCount) {
+    PartitionLocation[] locations = new PartitionLocation[size * 2];
+    for (int i = 0; i < size; i++) {
+      int endpointIndex = i % endpointCount;
+      PartitionLocation primary = newLocation(i, endpointIndex, 
PartitionLocation.Mode.PRIMARY);
+      PartitionLocation replica = newLocation(i, endpointIndex, 
PartitionLocation.Mode.REPLICA);
+      primary.setPeer(replica);
+      replica.setPeer(primary);
+      locations[i * 2] = primary;
+      locations[i * 2 + 1] = replica;
+    }
+    return locations;
+  }
+
+  private PartitionLocation newLocation(int id, int endpointIndex, 
PartitionLocation.Mode mode) {
+    return new PartitionLocation(
+        id,
+        0,
+        "localhost-" + endpointIndex,
+        1001 + endpointIndex,
+        1002 + endpointIndex,
+        1003 + endpointIndex,
+        1004 + endpointIndex,
+        mode);
+  }
+
+  private PartitionLocationOld[] newOldLocationPairArray(int size, int 
endpointCount) {

Review Comment:
   The headline JOL numbers are not production-shaped here. This 8-argument 
constructor leaves `storageInfo` null, while the old baseline always allocates 
a `StorageInfo`; however, both `LifecycleManager` and `SlotsAllocator` pass a 
non-null `StorageInfo`, and protobuf deserialization reconstructs one as well. 
Each call also creates a fresh `"localhost-" + endpointIndex` string, so the 
old graph retains one host string per location even though the allocator paths 
reuse `WorkerInfo.host`, whereas the new interner collapses those artificial 
duplicates. Please build both graphs from shared endpoint fixtures and 
equivalent non-null storage metadata (or add a production-shaped scenario) 
before publishing the 79–84% reduction.



-- 
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]

Reply via email to