Skip to content

[Performance] Optimize tablet RPC deserialization#18248

Merged
jt2594838 merged 3 commits into
apache:masterfrom
Caideyipi:perf/tablet-rpc-deserialization
Jul 20, 2026
Merged

[Performance] Optimize tablet RPC deserialization#18248
jt2594838 merged 3 commits into
apache:masterfrom
Caideyipi:perf/tablet-rpc-deserialization

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Description

Reduce temporary allocations in the RPC insert path

  • Canonicalize tree-model tablet measurements in the mutable lists created by Thrift instead of allocating replacement lists.
  • Reuse canonical measurement string instances within batched tablet requests.
  • Preallocate the insert-tablet statement list to the request size.

Speed up tablet deserialization

  • Decode uncompressed PLAIN tablet timestamps and value columns directly, avoiding a decoder allocation and virtual decoder calls per column.
  • Deserialize each tablet's data type list once and reuse the resulting array for value decoding and statement construction.
  • Keep compressed and non-PLAIN decoding behavior unchanged.

Opt-in performance UT and comparison

TabletRpcDeserializationPerformanceTest is skipped by default. It retains the corresponding origin/master implementations and measures legacy/optimized paths in the same JVM with alternating order, current-thread CPU time, allocated bytes, five rounds, and median reporting.

Run it manually with:

mvn test -pl iotdb-core/datanode -Dtest=TabletRpcDeserializationPerformanceTest -Diotdb.tablet.rpc.deserialization.perf.enabled=true -Diotdb.tablet.rpc.deserialization.perf.decode.iterations=10000 -Diotdb.tablet.rpc.deserialization.perf.batch.iterations=10000 -Diotdb.tablet.rpc.deserialization.perf.reuse.iterations=10000

Local comparison environment: Intel Core i9-13900H, Windows, HotSpot JDK 17.0.15. The command was repeated twice; each execution used five interleaved rounds of 10,000 measured operations per path and reported the median.

Path CPU result vs. origin/master Allocated bytes/op
PLAIN tablet decode (64 INT64 columns x 256 rows) No repeatable gain (0.81x-1.00x) 0.8% lower
Batch statement parsing (32 tablets x 32 measurements x 16 rows) 1.13x-1.23x faster 20.0%-20.1% lower
Measurement canonicalization/reuse (64 tablets x 64 measurements) 1.13x-1.25x faster 86.0% lower

The stable gains come from batch parsing and in-place measurement reuse. The standalone PLAIN decoder benchmark confirms the expected per-column allocation reduction, but does not show a reproducible CPU improvement on this JIT, so no decoder CPU gain is claimed here. Peak-heap deltas were omitted because they varied with GC/heap expansion; allocated bytes per operation were stable across both runs.

Compatibility and verification

This change does not modify the Thrift IDL, wire format, configuration, or public insert behavior. The external RPC service already uses the zero-copy transport for binary fields, so this PR focuses on the remaining service-layer allocations and decoding work.

Verified with:

  • mvn test -pl iotdb-core/node-commons -Dtest=PathUtilsTest
  • Targeted compilation and JUnit execution of TabletDecoderTest
  • Targeted compilation and JUnit execution of TabletRpcDeserializationPerformanceTest, both disabled and opt-in benchmark modes
  • mvn spotless:apply -pl iotdb-core/node-commons,iotdb-core/datanode
  • mvn checkstyle:check -pl iotdb-core/node-commons,iotdb-core/datanode
  • git diff --check

The normal DataNode test command is currently blocked by unrelated existing compilation errors in generated Mode/Fill classes and locally installed Config APIs.


This PR has:

  • been self-reviewed.
  • added unit tests to cover the new code paths.
  • added opt-in benchmarks for the affected hot paths.
  • added comments/Javadocs for the non-trivial in-place canonicalization methods.

Key changed/added classes
  • ClientRPCServiceImpl
  • StatementGenerator
  • TabletDecoder
  • TabletRpcDeserializationPerformanceTest
  • PathUtils

Comment thread iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TabletDecoder.java Outdated
@jt2594838
jt2594838 merged commit e5651cb into apache:master Jul 20, 2026
41 checks passed
@jt2594838
jt2594838 deleted the perf/tablet-rpc-deserialization branch July 20, 2026 09:44
jt2594838 pushed a commit that referenced this pull request Jul 22, 2026
* [Performance] Optimize tablet RPC deserialization

* [Performance] Add tablet RPC deserialization benchmarks

* Address tablet deserialization review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants