Skip to content

port client CPU optimizations to hbase_2.0 - #331

Merged
WeiXinChan merged 1 commit into
oceanbase:hbase_2.0from
hhlgt:optimize/client-cpu-performance-hbase_2.0
Sep 1, 2026
Merged

port client CPU optimizations to hbase_2.0#331
WeiXinChan merged 1 commit into
oceanbase:hbase_2.0from
hhlgt:optimize/client-cpu-performance-hbase_2.0

Conversation

@hhlgt

@hhlgt hhlgt commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR ports the request/response hot-path optimizations from
obkv-table-client-java to the HBase 2.x client.

It reduces CPU usage and temporary object allocation in HBase Get, Batch Get,
Scan, and Put operations while preserving the existing HBase client APIs and
legacy decoding paths.

Changes

Read path

  • Consume compact ObHBaseCellBatch results directly for:
    • point Get
    • Batch Get
    • Scan
    • Query-and-Mutate results
  • Introduce OHBaseResultCell, an immutable Cell implementation backed
    directly by decoded K/Q/T/V arrays.
  • Avoid materializing intermediate List<ObObj> and unnecessary KeyValue
    copies on the compact result path.
  • Optimize pure-Get batch result mapping and preallocate result containers.
  • Reuse row-key arrays when assembling point Get and closestRowBefore results.
  • Preserve HBase cell ordering by family, qualifier, and descending timestamp.
  • Keep the generic ObObj/KeyValue path as a compatibility fallback.

Write path

  • Build HBase Put V2 requests using the compact cell representation provided by
    obkv-table-client-java.
  • Preallocate key, column-family, and cell containers.
  • Reuse contiguous qualifier/value byte arrays during synchronous request
    encoding.
  • Use ObBytesString views for sliced cell regions to avoid unnecessary clones.
  • Avoid duplicate value cloning when encoding Put cells with TTL.
  • Validate Put mutations directly from the original family/cell map without
    materializing deprecated compatibility structures.

Compatibility and safety

  • Preserve existing Table, Result, and Cell behavior.
  • Support both single-column-family and TableGroup result formats.
  • Preserve empty-result and existence-only Get semantics.
  • Validate malformed K/Q/T/V results and unexpected point-Get row keys.
  • Keep legacy result decoding available when compact results are unavailable.

Dependency

  • Upgrade obkv-table-client from 2.4.0 to 2.4.1-SNAPSHOT.
  • This PR depends on the corresponding CPU optimization changes in
    obkv-table-client-java.

Dependent PR: oceanbase/obkv-table-client-java#442

Tests

Added focused unit tests covering:

  • compact Batch Get result conversion and request ordering
  • compact Put request construction with and without TTL
  • point Get and closestRowBefore result processing
  • compact Scan result consumption
  • zero-copy/sliced qualifier and value handling
  • Put validation and maximum cell-size boundaries
  • OHBaseResultCell compatibility and TableGroup field ranges
  • malformed and empty result handling

Focused test result: 39 tests passed with 0 failures and 0 errors.

@hhlgt

hhlgt commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

AI Coding Review

审查范围:
Base: origin/hbase_2.0
Head: optimize/client-cpu-performance-hbase_2.0
Commits: 1
Target: HBase 2.x

[P1] BufferedMutatorParams.maxKeyValueSize 被静默忽略

位置:[OHBufferedMutatorImpl.java (line 184)]
HBase 2.x 版本存在与 master PR 相同的问题:
private final int maxKeyValueSize;
该字段从 BufferedMutatorParams 正确初始化,但 Put 校验改为:
ohTable.validatePutMutation((Put) mt);
导致字段后续完全未被使用,实际校验采用 OHTable 自身配置。
影响和修复方式与 master PR 相同:需要向 validatePutMutation 传入当前 mutator 的 maxKeyValueSize,并增加参数覆盖优先级测试。

依赖风险

同样依赖:
<table.client.version>2.4.1-SNAPSHOT</table.client.version>
需要确保 Table Client PR 先合入并发布可解析的 snapshot 或正式版本。

Review 结论

合入前需要修复 Mutator 参数失效问题,并验证依赖发布。

@WeiXinChan

Copy link
Copy Markdown
Contributor

LGTM

@WeiXinChan
WeiXinChan merged commit cf18fe0 into oceanbase:hbase_2.0 Sep 1, 2026
1 check passed
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