Setting NUMA CPU Affinity for TiKV Deployment with TiUP

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TiUP 部署 tikv 设置 NUMA CPU 亲和性

| username: TiDBer_r2nJcto0

[TiDB Usage Environment] Testing
[TiDB Version] 7.5.1
[Reproduction Path]
Set the value of tikv_servers.numa_node to “1,2,3,4,5” in the Tiup configuration file.
Execute the deployment, and the generated service script corresponds to:
exec numactl --cpunodebind=1,2,3,4,5 --membind=1,2,3,4,5 bin/tikv-server

[Encountered Problem: Phenomenon and Impact]
There are two physical machines, configured as: 2 CPUs, each with 16 cores and 32 threads, totaling 64 logical CPUs. Multiple data disks.
NUMA structure:
NUMA node0 CPU(s): 0-15,32-47
NUMA node1 CPU(s): 16-31,48-63

I want to start three TiKV instances on each physical machine, and each instance needs to be bound to specified CPU cores. I expect to use the following command method:
numactl -C 1-15 --membind=0 bin/tikv-server
numactl -C 32-47 --membind=0 bin/tikv-server
numactl -C 16-31 --membind=1 bin/tikv-server

However, TiUP does not support generating startup scripts in this way.
Does TiUP have source code? Is there an open-source repository?

[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: hey-hoho | Original post link

The repository for tiup is here:

Currently, it is indeed not possible to achieve the effect you mentioned. You can manually modify the process startup script.

| username: YuchongXU | Original post link

Deploy the best one.

| username: tony5413 | Original post link

Three TiKV instances are generally deployed on three physical machines.

| username: yytest | Original post link

TiUP may indeed not support generating startup scripts in the way you expect. Typically, TiUP generates a unified startup script to start the entire TiKV cluster, rather than generating individual scripts for each instance.

| username: TiDBer_r2nJcto0 | Original post link

Found it in the source code file, it actually supports the -C parameter.

Two configuration parameters are provided in the configuration file:
numa_node: “0”
numa_cores: “1-15”

cat embed/templates/scripts/run_tikv.sh.tpl

{{- if and .NumaNode .NumaCores}}
exec numactl --cpunodebind={{.NumaNode}} --membind={{.NumaNode}} -C {{.NumaCores}} bin/tikv-server \
{{- else if .NumaNode}}
exec numactl --cpunodebind={{.NumaNode}} --membind={{.NumaNode}} bin/tikv-server \