apache / fury

A blazingly fast multi-language serialization framework powered by JIT and zero-copy.
https://fury.apache.org/
Apache License 2.0
3.11k stars 248 forks source link

[Java] Configurable buffer size limit #1950

Open theigl opened 1 day ago

theigl commented 1 day ago

Question

Since https://github.com/apache/fury/commit/01f1b66383a127a801f22ebe7fac5ca54d675878 Fury's internal MemoryBuffer is reset to 128k after every use.

The change makes sense because it reclaims memory that could otherwise sit unused, but it will cause massive allocations if most of the object graphs you serialize are >= 128k. In this case, a new buffer is allocated for every serialization.

In my application, most object graphs are 64k-512k leading to very frequent reallocation of the built-in buffer.

Currently, my only option is to manage a pool of MemoryBuffers myself and pass them to Fury instead of relying on the built-in buffer, but this makes using Fury significantly more complex.

Would it make sense to make the buffer size limit configurable? In my case, a 1MB limit would be ideal.

chaokunyang commented 1 day ago

Make sense, would you like to submit a PR to add a new field at FuryBuilder/Config and use that value for Buffer reset?