Skip to content

perf(S1): TPCH 10G 查询耗时翻倍 (+109%),二分定位到 #26706 (fix(lock): preserve bounded ranges for large DML batches) #27628

Closed

Description

@Ariznawlll

严重度: S1 — 性能回归

PR #26706 (fix(lock): preserve bounded ranges for large DML batches) 导致 TPCH 10G 全查询 sum(cost) 从 7,144ms 暴涨至 14,944ms(+109%),超过 25% 回归阈值。

影响范围

规模 正常耗时 回归耗时 变化
TPCH 1G 2,633 ms — ✅ 正常
TPCH 10G 7,144 ms 14,944 ms ❌ +109%
TPCH 100G 116,207 ms 229,585 ms ❌ +98%
TPCH 1T 1,328,307 ms 1,582,001 ms ✅ +19%(阈值内)

中等规模(10G/100G)查询耗时翻倍,影响所有 TPCH 查询。

二分定位

自动二分(5 轮,23 候选 commit)定位到:

First bad commit: 35db232dfc3be3264c4dc0d2547a3429624392fb
PR: #26706 — fix(lock): preserve bounded ranges for large DML batches
Author: @XuPeng-SH
Last good commit: 6742f958d4 (feat: ENGINE=KAFKA external table)

二分过程

轮次 Commit 判定 TPCH_10 cost (ms) Delta
Baseline 1909f795c good 7,144 —
Suspect bad 8dd1efc20 bad 19,883 +178%
Round 1 fddf53a26 bad 15,591 +118%
Round 2 249a458ba bad 15,553 +118%
Round 3 35db232df bad 15,177 +112%
Round 4 6742f958d good 8,768 +23%
Round 5 35db232df bad 14,944 +109% ✅

回归模式分析

100G 测试中 5 轮执行明细:

轮次 耗时 备注
Turn 1 138,464 ms 首轮正常
Turn 2 256,875 ms 第 2-5 轮翻倍
Turn 3 253,211 ms
Turn 4 255,214 ms
Turn 5 244,215 ms

首轮正常、后续翻倍 — 高度疑似 preserve bounded ranges 导致锁范围扩大,首轮数据加载后锁状态残留影响后续查询。

参考链接

/cc @XuPeng-SH @ck89119 @iamlinjunhong @aptend

Activity

  1. added
    kind/bug
    priority/p0
    and removed
    priority/p0
    on Aug 26, 2026
  2. added theissue type on Aug 26, 2026
  3. added this to the MO-202608 milestone on Aug 26, 2026
  4. LeftHandCold commented on Aug 26, 2026

    @LeftHandCold
    Collaborator

    这次 TPCC 下降不是正常波动。TPCC 部分可以高置信度定责到昨天合入的 PR #26706 (https://github.com/matrixorigin/matrixone/pull/26706),对应提交 35db232。具体瓶颈是该 PR 改造后的 远端 lock owner 按表释放路径,不是 B-tree 实际解锁变慢。

    当前任务使用 8dd1efc,上一次正常任务使用 b89a639,而 b89a639 正好是 #26706 合入前的基线。

    性能证据

    同配置、同资源、同测试拓扑下:

    场景 上次 本次 变化
    ━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━ ━━━━━━━ ━━━━━━━━
    10W / 10 terminals 5361 5385 +0.4%
    ──────────────────────── ─────── ─────── ────────
    10W / 100 terminals 19700 18234 -7.4%
    ──────────────────────── ─────── ─────── ────────
    100W / 100 terminals 25319 23070 -8.9%
    ──────────────────────── ─────── ─────── ────────
    100W / 1000 terminals 23918 16842 -29.6%
    ──────────────────────── ─────── ─────── ────────
    1000W / 1000 terminals 12435 8144 -34.5%

    这是典型的并发放大,而不是随机抖动:低并发基本正常,达到 1000 terminals 后锁 owner 饱和,吞吐稳定在更低的平台。

    以 100W/1000 为例:

    • lock-client RPC 平均延迟:9.95ms -> 15.09ms,增加约 52%
    • 事务完成速率:724/s -> 495/s,下降约 32%
    • 热点 lock owner CPU throttle:26.4% -> 45.9%
    • 每事务 lock RPC 数:27.3 -> 26.4,基本不变
    • 每事务 B-tree unlock 数:5.49 -> 5.46,基本不变
    • B-tree 实际 unlock:0.060ms -> 0.058ms,没有变慢

    1000W/1000 下 lock-client RPC 更是从 12.73ms 增加到 29.16ms,与 tpmC 下降同步。

    代码根因

    合入前,owner 收到一个远端 Unlock 请求后调用事务级 s.Unlock():

    旧版 service_remote.go (

    func (s *service) handleRemoteUnlock(
    ctx context.Context,
    cancel context.CancelFunc,
    req *pb.Request,
    resp *pb.Response,
    cs morpc.ClientSession) {
    err := s.Unlock(ctx, req.Unlock.TxnID, req.Unlock.CommitTS, req.Unlock.Mutations...)
    writeResponse(s.logger, cancel, resp, err, cs)
    )

    第一次请求会释放该 owner 上这个事务的全部锁。后续按表发来的请求通常变成廉价的 txn-not-found/no-op。

    #26706 合入后,owner 改成:

    新版 service_remote.go (https://github.com/matrixorigin/matrixone/blob/35db232dfc/pkg/lockservice/service_remote.go#L663-L676)

    每个远端表都分别执行 unlockRemoteLockTable(),每次都需要:

    1. 获取 transaction closure admission。
    2. 锁定 active txn generation。
    3. 校验 lock table bind generation。
    4. 进入 closing 状态并等待异步锁操作。
    5. 解锁当前表并更新 ledger。
    6. 最后一张表才能删除事务状态。

    这保证了 proxy handoff 和 table generation 的正确性,但把原来“一次完整处理加若干 no-op”变成了“每张表都走完整生命周期”。TPCC 每个事务涉及多张表,且热点 lock table 集中到一个 owner,于是产生 RPC 排队、owner CPU throttling和非线性吞吐下降。

    #26706 的 benchmark 仅覆盖单 service、单 table,没有覆盖 3 CN、多表远端 owner,因此没有发现这个回归。

    排除项

    PR #27548 (#27548) 不是根因。它调整的是全局 DNS resolver 的作用域,FileService 使用的 HTTP resolver 没有发生语义变化。

    另外,本次 nightly 的 TPCH 也出现了明显异常,并且集群创建阶段比前一天多等待约 9 分钟。这说明整轮任务还存在独立的基础设施或 AP 路径异常。但这些不能解释 TPCC 特有的“低并发正常、高并发 lock owner 饱和”以及 lock RPC 指标变化。TPCC 回归仍然可以单独定责到 #26706。

    修复不能简单回退 #26706,否则会重新引入 lock generation/proxy handoff 正确性问题。合理方向是保留按表校验语义,但将同一 owner 的多张表合并成一次 RPC、一次 closure admission 和一次 generation lock,并补充 3 CN、多表远端解锁基准。

  5. added a commit that references this issue on Aug 26, 2026
    4fea829
  6. Ariznawlll commented on Aug 31, 2026

    @Ariznawlll
    CollaboratorAuthor

    tpch性能已恢复

  7. added 3 commits that reference this issue on Sep 17, 2026
    515d6d1
    2952d45
    d8ad8ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s-1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions