---
title: 开启自动调优
description: "开启鲲鹏自动调优，任务的参数配置根据业务场景指标自动调优。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/devkit_24_t50/cliuserguide/KunpengDevKitCli_0090.html
sourcePath: /source/zh/kunpengdevkithistory/devkit_24_t50/cliuserguide/KunpengDevKitCli_0090.html
indexId: 51ad1bae099c01422493d02419c8498248eee6019c73b29388033040be9fe22985
---
# 开启自动调优

#### 命令功能

开启鲲鹏自动调优，任务的参数配置根据业务场景指标自动调优。


#### 命令格式

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


#### 参数说明


**表1 参数说明**

| 参数 | 参数选项 | 说明 |
| --- | --- | --- |
| \-h/\-\-help | \- | 获取帮助信息。 |
| \-l/\-\-log\-level | 0/1/2/3 | 设置日志级别，默认为2。 0：日志级别为DEBUG。 1：日志级别为INFO。 2：日志级别为WARNING。 3：日志级别为ERROR。 |
| \-t/\-\-task\-cfg | \- | 指定任务的配置文件路径。 |
| \-p/\-\-param\-cfg | \- | 指定应用参数的配置文件路径。 |
| \-o/\-\-output | \- | 设置任务结果文件输出名称，若不指定则在当前目录生成格式为kat\-YMD\-HMS的文件。 |


#### 使用示例

```
devkit kat train -t /opt/template/template_xxxx/task_Postgresql.json -p /opt/template/template_xxxx/param_Postgresql.json
```

任务参数已在/opt/template/template_xxxx/task_Postgresql.json中配置，应用参数在/opt/template/template_xxxx/param_Postgresql.json中配置；结果将以性能数据降序显示。


返回信息如下：

```
[2024-12-31 08:15:58 UTC] [KAT] [message] - Create work space /home/kat_show/DevKit-CLI-24.0.T50-Linux-Kunpeng/train-20241231-161557
[2024-12-31 08:16:09 UTC] [KAT] [message] - Application : Postgresql
[2024-12-31 08:16:09 UTC] [KAT] [message] - Tuning Direction : high
[2024-12-31 08:16:09 UTC] [KAT] [message] - ================================================================================
[2024-12-31 08:16:09 UTC] [KAT] [message] -           Kunpeng Auto Tuner - task set up
[2024-12-31 08:16:09 UTC] [KAT] [message] -           start time: 2024-12-31 08:16:09
[2024-12-31 08:16:09 UTC] [KAT] [message] - --------------------------------------------------------------------------------
[2024-12-31 08:16:18 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step   <params prepare>   start -----------------
[2024-12-31 08:17:24 UTC] [KAT] [message] - ================================================================================
[2024-12-31 08:17:24 UTC] [KAT] [message] -           Kunpeng Auto Tuner - base line test
[2024-12-31 08:17:24 UTC] [KAT] [message] -           start time: 2024-12-31 08:17:24
[2024-12-31 08:17:24 UTC] [KAT] [message] - --------------------------------------------------------------------------------
[2024-12-31 08:17:24 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step    <round set up>    start -----------------
[2024-12-31 08:17:24 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step      <run test>      start -----------------
[2024-12-31 08:18:21 UTC] [KAT] [message] -  ### Run test successfully. Performance of this round is [141.87] ###
[2024-12-31 08:18:21 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step  <round tear down>   start -----------------
[2024-12-31 08:18:25 UTC] [KAT] [message] - ================================================================================
[2024-12-31 08:18:25 UTC] [KAT] [message] -           Kunpeng Auto Tuner - round 1
[2024-12-31 08:18:25 UTC] [KAT] [message] -           start time: 2024-12-31 08:18:25
[2024-12-31 08:18:25 UTC] [KAT] [message] - --------------------------------------------------------------------------------
[2024-12-31 08:18:25 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step    <round set up>    start -----------------
[2024-12-31 08:18:25 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step   <assign params>    start -----------------
[2024-12-31 08:18:57 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step      <run test>      start -----------------
[2024-12-31 08:19:17 UTC] [KAT] [message] -  ### Run test successfully. Performance of this round is [159.93] ###
[2024-12-31 08:19:17 UTC] [KAT] [message] - --------- Kunpeng Auto Tuner - Step  <round tear down>   start -----------------
[2024-12-31 08:24:20 UTC] [KAT] [message] - ============================== Auto Tuning Report ==============================
[2024-12-31 08:24:20 UTC] [KAT] [message] - Total round : 5
[2024-12-31 08:24:20 UTC] [KAT] [message] - Total run   : 6
[2024-12-31 08:24:20 UTC] [KAT] [message] - Fail times  : 0
[2024-12-31 08:24:20 UTC] [KAT] [message] - Application  : Postgresql
[2024-12-31 08:24:20 UTC] [KAT] [message] - Tuning Direction : high
[2024-12-31 08:24:20 UTC] [KAT] [message] - Performance description: tpmC, transactions per minute
[2024-12-31 08:24:20 UTC] [KAT] [message] - Baseline performance  : 141.87
[2024-12-31 08:24:20 UTC] [KAT] [message] - Top 10 performance:
[2024-12-31 08:24:20 UTC] [KAT] [message] - --------------------------------------------------------------------------------
[2024-12-31 08:24:20 UTC] [KAT] [message] - |  Rank  |     Round     |  Performance   |  Improvement  (%) |
[2024-12-31 08:24:20 UTC] [KAT] [message] - --------------------------------------------------------------------------------
[2024-12-31 08:24:20 UTC] [KAT] [message] - |   1    |   round  5    |     174.94     |       23.31       |
[2024-12-31 08:24:20 UTC] [KAT] [message] - |   2    |   round  1    |     159.93     |       12.73       |
[2024-12-31 08:24:20 UTC] [KAT] [message] - |   3    |   round  3    |     155.5      |        9.61       |
[2024-12-31 08:24:20 UTC] [KAT] [message] - |   4    |   round  4    |     141.94     |        0.05       |
[2024-12-31 08:24:20 UTC] [KAT] [message] - |   5    |   round  2    |     114.16     |      -19.53       |
[2024-12-31 08:24:20 UTC] [KAT] [message] - --------------------------------------------------------------------------------
[2024-12-31 08:24:20 UTC] [KAT] [message] - Note:
[2024-12-31 08:24:20 UTC] [KAT] [message] - The performance value is the return value of the run test step,
[2024-12-31 08:24:20 UTC] [KAT] [message] - Performance improvement (%) =
[2024-12-31 08:24:20 UTC] [KAT] [message] -     (round performance - baseline performance) / baseline performance * 100
[2024-12-31 08:24:20 UTC] [KAT] [message] - Case package locate: /home/kat_show/DevKit-CLI-24.0.T50-Linux-Kunpeng/train-20241231-161557
[2024-12-31 08:24:20 UTC] [KAT] [message] - ================================================================================
```

自动调优后的参数集生成在/opt/template/template_xxxx/train-20241231-xxxxxx目录下，可根据调优结果选择参数集进行应用参数的调整。

```
ls /opt/template/template_xxxx/train-20241231-xxxxxx
```

返回信息如下：

```
param_cfg.json  task_cfg.json  train.db
```

该目录中包含应用的参数配置文件param_cfg.json，任务的参数配置文件task_cfg.json和自动调优后的数据文件train.db。
