Biranavan-Parameswaran commented on code in PR #2496:
URL: https://github.com/apache/systemds/pull/2496#discussion_r3636371150


##########
src/main/java/org/apache/sysds/runtime/controlprogram/federated/FederatedChunkProtocol.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.sysds.runtime.controlprogram.federated;
+
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
+
+final class FederatedChunkProtocol {
+       static final byte TYPE_DATA = 0;
+       static final byte TYPE_END = 1;
+       static final byte TYPE_ERROR = 2;
+
+       static final byte MARKER_LEGACY = 0;
+       static final byte MARKER_CHUNKED = 1;
+       static final long STREAM_THRESHOLD = 1536L << 20; // ~1.5 GB: route 
below this through the legacy object codec

Review Comment:
   Good suggestion, but `INT_MAX-1` is actually unsafe here. Routing uses a 
size estimate, not the exact wire size, and the `ObjectEncoder` overflows its 
`Integer.MAX_VALUE` `ByteBuf` once serialization framing is added. I measured 
that cliff at about 1.990 GiB, so an estimate just under `INT_MAX` can still 
overflow on the wire. I set the threshold to `2000L << 20` (about 1.953 GiB), 
roughly 40 MB under the cliff, so the regular encoder is used as high as we 
safely can.
   
   Note the routing also changed since your review. Responses now route by 
lineage cacheability instead of size, so `STREAM_THRESHOLD` is now the size 
guard on the object encoder path rather than the main router.



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