anton-vinogradov commented on code in PR #13462:
URL: https://github.com/apache/ignite/pull/13462#discussion_r3769796800


##########
modules/core/src/main/java/org/apache/ignite/internal/managers/communication/CommunicationMarshalling.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.ignite.internal.managers.communication;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.jetbrains.annotations.Nullable;
+
+/** Marshalling of the communication transport, which speaks the schema-aware 
marshaller. */
+public final class CommunicationMarshalling {

Review Comment:
   Measured it. Binary is faster on every payload a message field actually 
carries, except exceptions, where the two are equal.
   
   Round trip (marshal + unmarshal), corretto-17, 2000 warmup + 20000 
iterations, three runs, numbers from the last one:
   
   | payload | jdk, us/op | binary, us/op | speedup | jdk, bytes | binary, 
bytes |
   |---|---|---|---|---|---|
   | small POJO | 6.21 | 3.43 | 1.8x | 121 | 40 |
   | list of 100 POJOs | 57.72 | 22.24 | 2.6x | 2048 | 4196 |
   | map of 50 String to UUID | 14.95 | 5.38 | 2.8x | 1626 | 1346 |
   | exception with a cause | 20.59 | 24.79 | 0.83x | 2138 | 2144 |
   | CacheConfiguration | 27.60 | 7.60 | 3.6x | 3432 | 636 |
   | QueryEntity | 7.74 | 1.48 | 5.2x | 783 | 161 |
   
   Two results are worth reading carefully.
   
   **Exceptions are a tie, and that is expected.** `Throwable` declares 
`writeObject`, so `BinaryUtils.isCustomJavaSerialization` sends it to 
`OptimizedMarshaller` - the binary format never runs. That is also why 
`ErrorMessage` pins jdk in this PR: binary buys nothing there and would only 
register the class name of every new exception type cluster-wide.
   
   **Binary is bigger on a list of equal objects.** It writes the schema per 
object, while jdk writes the class descriptor once and back-references it. On 
everything else binary is smaller, up to 5x on `CacheConfiguration`.
   
   The schema processing you asked about is what pays for itself here: it is 
written per object, but reading does not walk the whole graph.
   
   The benchmark is a throwaway test class, not part of the PR. It builds both 
marshallers the way tests do - `Marshallers.jdk()` and 
`createStandaloneBinaryMarshaller()` - and times `U.unmarshal(marsh, 
U.marshal(marsh, obj), loader)` in a loop. I can attach it if you want to 
re-run it.
   



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