This is the source code to the paper "AgentTune: A Multi-Agent Collaborative Framework for Database Knob Tuning". Please refer to the paper for the experimental details.
In our experiments, We conduct experiments on MySQL 5.7.
-
Preparations: Python == 3.10
-
Install packages
pip install -r requirements.txt pip install . -
Download and install MySQL 5.7 and boost
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.19.tar.gz sudo cmake . -DCMAKE_INSTALL_PREFIX=PATH_TO_INSTALL -DMYSQL_DATADIR=PATH_TO_DATA -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=PATH_TO_BOOST; sudo make -j 16; sudo make install;
Download and install
git clone https://github.com/akopytov/sysbench.git
./autogen.sh
./configure
make && make installLoad data
sysbench --db-driver=mysql --mysql-host=$HOST --mysql-socket=$SOCK --mysql-port=$MYSQL_PORT --mysql-user=root --mysql-password=$PASSWD --mysql-db=sbtest --table_size=800000 --tables=150 --events=0 --threads=32 oltp_read_write prepare > sysbench_prepare.outDownload IMDB Data Set from http://homepages.cwi.nl/~boncz/job/imdb.tgz.
Follow the instructions of https://github.com/winkyao/join-order-benchmark to load data into MySQL.
Follow the instructions of https://www.tpc.org/default5.asp to prepare TPC benchmarks.
- Modify
config.ini - Set benchmark path in
./configuration recommender/DB_client.py - Run
./run.bash
The four agents in AgentTune—Workload Analyzer, Knob Selector, Range Pruner, and Configuration Recommender—will execute sequentially. Intermediate results will be saved to the location you specified in config.ini, and all tuning records and results will be stored in the ./configuration recommender/record directory.
This section introduces how to expand AgentTune to encompass new database scales, engines, and hardware environments. Detailed experimental results and analysis can be found in Section 8.3 of the paper.
When the database scale changes, simply modify config.ini by setting:
database_scale= new database scaledatabase_name= DB_Name (If you create a new database)
When the hardware environment changes, simply modify config.ini by setting:
hardware= new hardware configuration
-
Download and install the new database engine
-
Prepare workload in the new database engine
-
Prepare candidate knobs
In
./knob selector/get_candidate_knobs/, we use MySQL as an example to demonstrate how to quickly obtain candidate knobs by processing the official documentation. -
Modify database connection method and knob setting method in
./configuration recommender/DB_client.py -
Modify
config.iniby setting:database_kernel= new database enginedatabase_name= DB_Name
and other database configurations including DB_User, DB_Password, DB_Host and DB_Port.
This section introduces how to evaluate the effectiveness of each component in AgentTune and the impact of different large language models (LLMs). Detailed experimental results and analysis can be found in Section 8.4 of the paper.
The four agents in AgentTune execute sequentially and intermediate results for each component are saved to the location you specified in config.ini. So you are free to remove or replace any component to evaluate the effectiveness. However, since the subsequent pruning and tuning stages depend on the selected knobs from the Knob Selector, it is recommended to replace this step with alternative methods (e.g., manual selection or ML-based approaches) rather than removing it entirely.
To change the knob size in AgentTune, simply modify config.ini by setting:
knob_num= new knob size
To change the beam size in AgentTune, simply modify config.ini by setting:
top_k= new beam size
To change the LLM in AgentTune, simply modify config.ini by setting:
model= new large language model