Skip to content

sql/kv: resetForNewSQLTxn is inefficient and allocation heavy #32508

@nvb

Description

@nvb

screen shot 2018-11-20 at 7 36 23 am

resetForNewSQLTxn is full of low hanging fruit that is ready to be plucked. I've repeatedly observed the function come up in benchmarks. Currently I'm seeing it account for 4.59% of CPU utilization and 9.15% of total allocated memory in sysbench's oltp_point_select workload. If #32427 (comment) is any indication, there's a big win sitting here.

The two biggest offenders in the function are client.NewTxn and tracing.StartRootSpan. The former adds more weight behind the argument that we need to start pooling client.Txn and especially kv.TxnCoordSender objects. I don't know much about the latter, other than that I've talked to @andreimatei about this before and I remember we we're doing something strange with tracing even when it's not enabled just so that we could enable it mid-transaction. We should fix that.

cc. @andreimatei @jordanlewis

Jira issue: CRDB-4741

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-kv-clientRelating to the KV client and the KV interface.A-sql-executorSQL txn logicC-performancePerf of queries or internals. Solution not expected to change functional behavior.T-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions