Skip to content

[Refactoring]: reuse TxnOperator for one session #18601

Closed

Description

@ouyuanning

Why do you want to refactor this code?

目前每次执行都会新建一个TxnOperator句柄。
位置:
frontend/txn.go 
createUnsafe 函数的  err = th.createTxnOpUnsafe(execCtx)   这里
看是否可复用

Describe the solution you'd like

看句柄是否可在session内复用。新的statement执行前或后 reset 一下就好了

Describe alternatives you've considered

No response

Additional information

No response

Activity

  1. added this to the 1.3.0 milestone on Sep 7, 2024
  2. zhangxu19830126 commented on Sep 11, 2024

    @zhangxu19830126
    Contributor

    @daviszhen add new restartTxn interface to reuse.

  3. modified the milestones: 2.0.0, 2.1.0 on Nov 4, 2024
  4. daviszhen commented on Nov 13, 2024

    @daviszhen
    Contributor

    已经修改。
    分成4个pr做的。4个pr之间还有其它人的pr.

    前后对比 结果存在误差。

    image

  5. daviszhen commented on Nov 13, 2024

    @daviszhen
    Contributor

    中间有其他人的pr, 感觉体现不出来效果。
    qps反而下降了。。。。
    测试脚本没抓到pprof,不能在pprof上看出来

    @:~/Documents/mo-load$ cat result_issue_18601.md 
    |          |   QPS_before |   RT_MAX_before |   RT_MIN_before |   QPS_after |   RT_MAX_after |   RT_MIN_after |   QPS_Change_Percent |
    |:---------|-------------:|----------------:|----------------:|------------:|---------------:|---------------:|---------------------:|
    | select_1 |        72650 |              58 |               0 |       71895 |             52 |              0 |             0.989608 |@:~/Documents/mo-load$ 
    
  6. jensenojs commented on Nov 13, 2024

    @jensenojs
    Contributor

    我明天来测一下这个pprof

  7. ouyuanning commented on Nov 13, 2024

    @ouyuanning
    ContributorAuthor

    只要prepare测试的profile里没有了新建TxnOperator的耗时应该就可以了。

  8. daviszhen commented on Nov 14, 2024

    @daviszhen
    Contributor

    从 @jensenojs 拿到了前后的profile.

    修改前:txnclient.New 20.28s 占比 5.6%

    image

    修改后:restarttxn 15.55s 占比 4.3%

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions