heliang666s opened a new pull request, #15616:
URL: https://github.com/apache/dubbo/pull/15616

   ### Optimize Triple POJO Serialization with Zero-Copy
   
   #### What is the purpose of this PR?
   
   This PR introduces a significant **zero-copy optimization** for POJO 
serialization within the Dubbo Triple protocol's wrapper mode. It targets UNARY 
RPC calls to dramatically reduce memory allocation and improve performance.
   
   #### Why is this change necessary?
   
   Previously, serializing multiple POJO parameters involved creating an 
intermediate `byte[]` for each parameter. This led to:
   - High memory allocation and churn.
   - Increased GC pressure, impacting overall application performance.
   - Performance bottlenecks due to memory copy operations.
   
   #### How did you implement it?
   
   The core of this optimization is a **dual-phase streaming mechanism** for 
**UNARY** RPC calls:
   
   1.  **Phase 1: Size Calculation (Allocation-Free)**
       A lightweight `CountingOutputStream` calculates the serialized size of 
each parameter *without* allocating memory.
   
   2.  **Phase 2: Direct Serialization**
       The parameters are serialized directly to the network output stream, 
prefixed with their calculated length.
   
   To maintain backward compatibility, this new format is identified by 
appending a `-streaming` suffix to the serialization type (e.g., 
`hessian4-streaming`). The server detects this suffix and uses a corresponding 
streaming decoder.
   
   The optimization automatically **falls back to the traditional method** for 
streaming RPCs (SERVER_STREAM, BI_STREAM) and non-capable serializations, 
ensuring no breaking changes.
   
   #### What are the key benefits?
   
   - **Reduced Memory Allocation:** Eliminates intermediate `byte[]` buffers 
for parameters.
   - **Lower GC Pressure:** Significantly fewer objects for the garbage 
collector to manage.
   - **Improved Performance:** Faster serialization/deserialization by avoiding 
memory copies.
   - **Full Backward Compatibility:** The new mechanism is interoperable with 
older clients/servers and gracefully degrades when not applicable.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to