the-other-tim-brown commented on code in PR #13614:
URL: https://github.com/apache/hudi/pull/13614#discussion_r2232219741


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/BufferedRecordSerializer.java:
##########
@@ -31,52 +31,81 @@
 
 /**
  * An implementation of {@link CustomSerializer} for {@link BufferedRecord}.
- *
  */
 public class BufferedRecordSerializer<T> implements 
CustomSerializer<BufferedRecord<T>> {
-  public static final int KRYO_SERIALIZER_INITIAL_BUFFER_SIZE = 1048576;
-  private final Kryo kryo;
-  // Caching ByteArrayOutputStream to avoid recreating it for every operation
-  private final ByteArrayOutputStream baos;
+  // Caching kryo serializer to avoid creating kryo instance for every serde 
operation
+  private static final ThreadLocal<InternalSerializerInstance> SERIALIZER_REF =

Review Comment:
   This is using ThreadLocal so that each thread will have its own copy. You 
don't need to make new copies per usage on that thread as a result.
   
   In ExternalSpillableMap we used `SerializationUtils` in the past which uses 
the same approach. The approach is aligned with the [kryo 
docs](https://github.com/EsotericSoftware/kryo?tab=readme-ov-file#pooling) 



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