E2ETune-AI4DB is an end-to-end database tuning and evaluation workspace built around an abstraction-first design. The core logic lives under classes/, where database runners, workload collectors, surrogate models, tuners, and workload feature extractors are separated behind shared base classes so the system can be extended to another database engine without rewriting the entire pipeline.
The most important parts of the codebase are:
main.pyfor the main two-phase tuning workflow.classes/for the abstraction layer and engine-specific implementations.inferencing/for replaying and evaluating candidate knob configurations.run_diverse_configs.pyfor replaying precomputed diverse configurations.config/config.yamlfor the primary runtime configuration.
Install Python dependencies with:
pip install -r requirements.txtExternal components are still required for execution:
- PostgreSQL for OLAP/PG-based runs.
- MySQL for MySQL-backed runs.
- BenchBase for OLTP workload execution.
For BenchBase, build the PostgreSQL profile as usual:
git clone --depth 1 https://github.com/cmu-db/benchbase.git
cd benchbase
./mvnw clean package -P postgresThe current workflow uses only config/config.yaml.
That file controls:
- database connection details
- benchmark name, type, and workload directory
- tuning method and iteration settings
- surrogate model path
- knob definition file
The tuning code also depends on:
knob_config/for knob rangesrepresentative_workloads_sampled.jsonfor Phase 1 workload sampling10_diverse_configs_all.jsonfor the diverse-config replay flow
The repo is structured so the concrete database logic sits behind reusable interfaces:
classes/base_classes/Database.pydefines the shared database contract.classes/base_classes/Data_Collector.pydefines the common collection flow.classes/base_classes/Tuner.pyandclasses/HEBO_Tuner.pyseparate tuning policy from database execution.classes/base_classes/Workload_Runner.pyprovides workload task definitions used across scripts.classes/base_classes/Surrogate_Strategy.pyandclasses/Cost_Model.pyisolate surrogate behavior.
Engine-specific implementations such as classes/PostgreSQL_Database.py, classes/MySQL_Database.py, and classes/BenchBase_Database.py plug into the same flow. That makes it straightforward to add another database by implementing the same base contracts and wiring the new backend into the entry point.
main.py is the primary entry point. It scans the benchmark workload folder and then runs:
- Phase 1: real execution on representative workloads sampled from
representative_workloads_sampled.json - Phase 2: surrogate-based tuning for the remaining workloads
It also resumes from existing performance records and can be forced into surrogate-only mode through the YAML tuning config.
Example:
python main.py --config config/config.yaml --dbengine postgresql --servername hetzner-4c-8t-32gbOutputs are written to:
data/{dbengine}/{servername}/{benchmark}/{workload}/logs/tuning/
The inferencing/ folder contains scripts for collecting workload data and replaying candidate configurations against a live database.
inferencing/collect_data.pycollects internal metrics, query plans, and workload features for one SQL file.inferencing/evaluate_config.pycompares the default config against one chosen best config.inferencing/evaluate_all_configs.pyreplays a full JSON list of candidate knob buckets and tracks the best one.
Examples:
python inferencing/collect_data.py path/to/workload.sql
python inferencing/evaluate_config.py path/to/workload.sql
python inferencing/evaluate_all_configs.py --sql_file path/to/workload.sql --configs_json path/to/configs.jsonrun_diverse_configs.py replays precomputed diverse knob settings from 10_diverse_configs_all.json.
python run_diverse_configs.py --config config/config.yaml --dbengine mysql --servername hetzner-4c-8t-64gbUse --skip-configs if you only want default data collection without running the replayed configurations.
The llm_tuning/ folder contains notebook-based experiments for fine-tuning and adapter-based inference. Those notebooks assume the broader LLaMA-Factory / Hugging Face workflow described in the notebook cells themselves.
The published base model is available at:
springhxm/E2ETune
The most important generated folders are:
data/for collected tuning artifactslogs/for tuning and workload logsanalysis_output/for SQL analysis, candidates, and evaluation resultsresults/for diverse-config replay outputs
- OLTP workloads are executed through BenchBase configuration files in
oltp_workloads/. - OLAP workloads are stored under
olap_workloads/and are typically replayed directly against the database. - The repository mixes older helper scripts with newer refactored code, so check the script-specific help text before running any command.