Rate This Document
Findability
Accuracy
Completeness
Readability

Enabling Automatic Tuning

After this command is run, the Kunpeng AutoTuner tunes parameters in the parameter spaces based on service scenario metrics.

Command Function

Starts automatic tuning. The Kunpeng AutoTuner automatically tunes task parameters based on service scenario metrics.

Syntax

1
devkit kat train [-h] [-l {0,1,2,3}] -t <file> [-p <file>] [-o <dir>]

Parameter Description

Table 1 Parameter description

Parameter

Option

Description

-h/--help

-

Obtains help information. This parameter is optional.

-l/--log-level

0/1/2/3

Log level, which defaults to 2. This parameter is optional.
NOTE:

The default level is 2 (WARNING).

  • 0: DEBUG
  • 1: INFO
  • 2: WARNING
  • 3: ERROR

-t/--task-cfg

-

Path to the task configuration file. This parameter is mandatory.

-p/--param-cfg

-

Path to the configuration file of application parameters. This parameter is optional.

NOTE:

If only the Kunpeng uarch parameter is enabled, the -p option is optional. In other cases, the -p option is required.

Kunpeng uarch is a microarchitecture parameter.

-o/--output

-

Output directory of the task result file. If you do not set this parameter, a folder in the format of train-YMD-HMS format is generated in the current directory. Do not use an existing directory. This parameter is optional.

Example

The following uses PostgreSQL as an example.

  1. Enable automatic tuning.
    devkit kat train -t /opt/template/template_PostgreSQL_20250721_091524/task_PostgreSQL.yaml -p /opt/template/template_PostgreSQL_20250721_091524/param_PostgreSQL.yaml -o /opt/template/train

    The task parameters have been configured in the /opt/template/template_PostgreSQL_20250721_091524/task_PostgreSQL.yaml file and the application parameters have been configured in the /opt/template/template_PostgreSQL_20250721_091524/param_PostgreSQL.yaml file. The results are displayed in descending order of performance data.

    Command output:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    [2025-07-22 01:58:00 UTC] [KAT] [message] - ================================== Round Info =================================
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] -         Case        |    Round     | Performance  | Difference   |Improvement (%)
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] -       Baseline      |      0       |    85.61     |      --      |      --      
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] -         Best        |      1       |    115.75    |    30.14     |       35.21  
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] -        Worst        |      5       |    86.97     |     1.36     |        1.59  
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Note:
    [2025-07-22 01:58:00 UTC] [KAT] [message] -     This table compares performance across the baseline, best, and worst rounds. 
    [2025-07-22 01:58:00 UTC] [KAT] [message] - The gap between the best and worst rounds indicates the impact of the parameter 
    [2025-07-22 01:58:00 UTC] [KAT] [message] - space on overall performance.
    [2025-07-22 01:58:00 UTC] [KAT] [message] - ================================== Param Diff =================================
    [2025-07-22 01:58:00 UTC] [KAT] [message] -  Group |   Parameter   |Baseline |  Best   |  Worst  | Importance |    Range    
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Postgre|  wal_buffers  |  115125 | 127736  | 147579  |   4.79%    |[-1, 262144] 
    [2025-07-22 01:58:00 UTC] [KAT] [message] -   SQL  |               |         |         |         |            |             
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Postgre|wal_receiver_ti|   6214  |  5948   |  9023   |   4.57%    | [0, 12000]  
    [2025-07-22 01:58:00 UTC] [KAT] [message] -   SQL  |     meout     |         |         |         |            |             
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Postgre|autovacuum_anal|0.2515112|0.3773385|0.1809016|   4.44%    |[0.001, 0.5] 
    [2025-07-22 01:58:00 UTC] [KAT] [message] -   SQL  |yze_scale_facto|         |945195332|030090553|            |             
    [2025-07-22 01:58:00 UTC] [KAT] [message] -        |       r       |         |         |         |            |             
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Postgre|backend_flush_a|   125   |   190   |   97    |   4.30%    |  [0, 256]   
    [2025-07-22 01:58:00 UTC] [KAT] [message] -   SQL  |     fter      |         |         |         |            |             
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Postgre|maintenance_wor|   15    |   21    |   11    |   4.15%    |   [1, 64]   
    [2025-07-22 01:58:00 UTC] [KAT] [message] -   SQL  |     k_mem     |         |         |         |            |             
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Note:
    [2025-07-22 01:58:00 UTC] [KAT] [message] -     This table shows the parameter differences between the baseline round and the 
    [2025-07-22 01:58:00 UTC] [KAT] [message] - best and worst rounds throughout the training. The table is sorted by parameter 
    [2025-07-22 01:58:00 UTC] [KAT] [message] - importance, displaying the top 5 parameters or parameters whose importance sum 
    [2025-07-22 01:58:00 UTC] [KAT] [message] - exceeds 60%. Items marked with "--" indicate parameter values cannot be obtained. 
    [2025-07-22 01:58:00 UTC] [KAT] [message] - ============================== Auto Tuning Report ==============================
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Total round             : 5
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Total run               : 6
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Fail times              : 0
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Tuning direction        : high
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Algorithm               : HPO
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Performance description : tpmC, transactions per minute
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Parameter groups        : PostgreSQL
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Baseline performance    : 85.610
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Top 10 performance :
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - |  Rank  |     Round     |  Performance   |  Improvement  (%) |
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - |   1    |   round  1    |    115.750    |       35.21       |
    [2025-07-22 01:58:00 UTC] [KAT] [message] - |   2    |   round  2    |    103.820     |       21.27       |
    [2025-07-22 01:58:00 UTC] [KAT] [message] - |   3    |   round  3    |     91.310     |        6.66       |
    [2025-07-22 01:58:00 UTC] [KAT] [message] - |   4    |   round  4    |     87.040     |        1.67       |
    [2025-07-22 01:58:00 UTC] [KAT] [message] - |   5    |   round  5    |     86.970     |        1.59       |
    [2025-07-22 01:58:00 UTC] [KAT] [message] - --------------------------------------------------------------------------------
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Note:
    [2025-07-22 01:58:00 UTC] [KAT] [message] - The performance value is the return value of the run test step,
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Performance improvement (%) =
    [2025-07-22 01:58:00 UTC] [KAT] [message] -     (round performance - baseline performance) / baseline performance * 100
    [2025-07-22 01:58:00 UTC] [KAT] [message] - Case package locate: /opt/template/train/train-20250722-015800
    

    The parameter sets after automatic tuning are generated in the /opt/template/train/train-20250722-015800 directory. You can select a parameter set based on the tuning result to adjust application parameters.

    In the example, the performance metric is tpmC and the baseline performance is 85.610. After five rounds of automatic tuning, the optimal performance reaches 115.750, presenting an increase of 35.21% over the baseline performance. The directory for saving the tuning result file is provided at the end of the command output, and can be used in subsequent tuning result processing.

    In PostgreSQL database performance tests, tpmC is a key performance metric derived from the TPC-C benchmark.

  2. View the parameter set after automatic tuning is complete.
    ls /opt/template/train/train-20250722-015800

    Command output:

    1
    kat_run.log  param_cfg.yaml  task_cfg.yaml  train.db
    

    The directory contains the execution log file kat_run.log and the data file train.db. param_cfg.yaml and task_cfg.yaml are the copied template files.