imbajin opened a new pull request, #3390: URL: https://github.com/apache/hugegraph/pull/3390
## Purpose of the PR Avoid quadratic buffer copying when LZ4 encodes large incompressible values. BytesBuffer previously reallocated to the requested capacity plus 64 bytes; repeated 4 KiB writes copied a growing buffer hundreds or thousands of times. ## Main Changes Use geometric capacity growth with long arithmetic and the existing maximum-capacity clamp. Preserve wrapped-buffer behavior, written prefixes, serialization output and task/property size limits. Only the Struct buffer and its regression tests change. ## Verifying these changes - [x] editorconfig:format and module/dependency clean compile. - [x] Complete Struct package/unit/legacy codec tests: 136 passed, including growth, maximum-capacity, prefix integrity and incompressible compression round trips. - [x] 8 MiB seeded incompressible LZ4 microbenchmark (1 warmup, 3 samples): median 696.756 → 11.064 ms; reallocations 690 → 1; copied prefixes 4.836 GB → 5.591 MB. Compressed bytes and SHA-256 are identical. - [x] Local source-built hstore Server: the same 12,000-vertex, 8 KiB-property async task rejects its 99,665,305-byte result at the unchanged 16,777,216-byte limit in 1.600 s instead of 126.471 s (single end-to-end observations). This speeds up rejection; it does not make oversized task results supported. ## Does this PR potentially affect the following parts? - [x] Nope: no API, configuration, dependency or binary-format changes - [ ] Dependencies - [ ] Modify configurations - [ ] The public API ## Documentation Status - [ ] `Doc - TODO` - [ ] `Doc - Done` - [x] `Doc - No Need`: internal allocation strategy; reproducible benchmark evidence is provided in the paired Toolchain performance report. Tradeoff: geometric growth can reserve additional spare capacity, still bounded by the existing configured maximum. The local comparison replaced only the Server Struct JAR; 169 of 173 class files are byte-identical, and three changed nested classes have identical disassembly (debug line offsets only). Raw samples, exact commands and deployment provenance: https://github.com/hugegraph/hugegraph-toolchain/pull/80 (see COMPARISON.md and scripts/COMPRESSION.md). Paired visualization changes: https://github.com/hugegraph/hugegraph-toolchain/pull/79. ## 图解  序列化缓冲区扩容机制:优先几何增长以减少增量写入的重复复制,同时保留最大容量约束。额外预留空间是权衡,不表示评审、CI 或性能验收已通过。 --- Source community PR: https://github.com/hugegraph/hugegraph/pull/327. This upstream draft reuses the same branch. Figure PR numbers refer to that community source. -- 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]
