Skip to content

Build TiDB with PGO #57502

@crazycs520

Description

@crazycs520

Enhancement

Reference: Profile-guided optimization

Build TiDB with PGO has 2% ~ 5% QPS increase in sysbench workloads.

Following Build With PGO test is build TiDB with oltp_point_select CPU profile.

sub-cmd Version Thread QPS AVG Duration QPS Increase
oltp_point_select Origin 128 159274 0.80ms  
oltp_point_select Build With PGO 128 168106 0.76ms 5.5%
oltp_read_only Origin 128 98615 N/A   
oltp_read_only Build With PGO 128 101047 N/A  2.5%
oltp_index_lookup Origin 128 43767 2.92  
oltp_index_lookup Build With PGO 128 46076 2.78 5%

Cluster topology

Component Num GCP instance CPU Core Memory Disk
TiKV 3 n2-standard-16 16C 64G 500G
PD 1 n2-standard-16 16C 64G 100
TiDB 2 n2-standard-16 16C 64G N/A
workload 1 n2-standard-16 16C 64G N/A

Build With PGO Step

  1. Run sysbench point-get workload and grab TiDB CPU profile file.
sysbench --config-file=sysbench.conf oltp_point_select --tables=16 --table-size=1000000 --threads=128 run
curl "http://$TiDB_ID:10080/debug/pprof/profile?seconds=30" > default.pprof
  1. Build TiDB with pgo:
CGO_ENABLED=1  GO111MODULE=on go build -pgo=/dir/default.pprof -tags codes  -ldflags '-X "github.com/pingcap/tidb/pkg/parser/mysql.TiDBReleaseVersion=v8.5.0-alpha-134-g4a6bf46a5f" -X "github.com/pingcap/tidb/pkg/util/versioninfo.TiDBBuildTS=2024-11-17 18:31:07" -X "github.com/pingcap/tidb/pkg/util/versioninfo.TiDBGitHash=4a6bf46a5f7eb494412a342345bffc5c22f5e663" -X "github.com/pingcap/tidb/pkg/util/versioninfo.TiDBGitBranch=master" -X "github.com/pingcap/tidb/pkg/util/versioninfo.TiDBEdition=Community" ' -o bin/tidb-server ./cmd/tidb-server

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions