This code is the experimental implementation from the paper "Symmetry-Preserving Architecture for Multi-NUMA Environments (SPANE): A Deep Reinforcement Learning Approach for Dynamic VM Scheduling" (arxiv). The experimental environment for scheduling in this study is built upon modifications to VMAgent, a platform designed for applying Reinforcement Learning (RL) to Virtual Machine (VM) scheduling tasks. If you have any questions, feel free to contact the main author at chantp@sjtu.edu.cn.
This project is licensed under the MIT License - see the LICENSE file for details.
The VM dataset used in this paper is the Huawei-East-1 dataset from Huawei Cloud. The original dataset is available at data/Huawei-East-1.csv. In our environment, VMs may experience delays, meaning their start times are not fixed. Therefore, we modify the dataset format to treat the VM's runtime (lt, length time) as an inherent property of the VM.
The scheduling environment used in this study is implemented in the schedgym/sched_env.py. This environment interacts with the RL agent by processing actions through the step function, which returns the next_state, reward, and done flag. Here, server index starts from 0.
There are two termination conditions for the environment.
- The environment terminates after scheduling a certain number of VMs.
- The environment terminates when the first VM cannot be immediately deployed, plus an additional number of scheduled VMs.
When selecting the VM queue, we first pick an initial VM from the dataset and apply the first-fit scheduling strategy until encountering the first VM that cannot be deployed. The total number of scheduled VMs under this first-fit strategy, plus 40, determines the length of the VM queue corresponding to this initial VM.
There are two main types of RL agents:
- Agents that use heuristic methods, located in the
baseline_agentfolder. For more details, refer to the comments inside, including those in__init__.py. Usebaseline.pyto obtain their performance. - Neural network agents trained with DQN, located in the
dqnfolder.
The para_search_{method}.py and train.py scripts are designed for hyperparameter optimization and agent generation. The method variable can be set to one of the following algorithms: SPANE, MLPDQN, or MLPAUG. Specifically, train.py serves as the training execution script, while para_search_{method}.py manages parallel runs of the training process. The following is an introduction to the code and results, with the last paragraph providing implementation suggestions.
When executing para_search_{method}.py, it generates a folder log_para_{time} to store experimental outcomes, and the parameters of the top_k strongest-performing models across all trials are stored in the models/{method} folder. Users may customize the hyperparameter search space (param_space), total number of trials (total_trials), number of parallel tasks (concurrent_trials), whether to save the model (save_model), and number of stored models top_k within para_search_{method}.py. You can select the trial configuration generation method by commenting out specific sections of code.
The log_para_{time} directory organizes results as follows:
- The
figsubfolder contains distribution plots visualizing hyperparameter performance. - The
resultsubfolder stores the hyperparameters and corresponding results for each experiment. - The
all_results.jsonfile gather the outcomes of all experiments. - The
tensorboardsubfolder stores model checkpoints and training progress (e.g., loss curves) for each experiment. Inside each experiment's specific directory, themodelssubfolder contains the trained model parameters.
To view process data, use the command:
tensorboard --logdir=log_para_{time}This command displays data for all experiments. To view data for a specific experiment, replace the logdir parameter with the corresponding experiment directory, e.g.,
tensorboard --logdir=log_para_{time}/{trial_id}_dqnThe suggested approach (which is also the one used in this paper) is as follows:
- Set a broad hyperparameter space and use random combination to generate hyperparameter sets. After running the experiments, analyze the plots in the
figfolder and eliminate the poor-performing hyperparameter values. - Once you have a smaller hyperparameter space, use normal combination to find the best hyperparameter set.
- After identifying the best hyperparameters, set
save_model=Trueand run experiments to store models' parameters. Notice that foldermodels/{method}currently stores the model parameters used in the paper.
The files wait_time_scheduler.py, wait_time_exp.py and wait_time_stats.py are used to analyze the wait time of different methods (Section V-B).
wait_time_exp.pyruns 1,000 experiments for a single model and generate the results.wait_time_scheduler.pyis responsible for running these experiments in parallel.wait_time_stats.pyis used to summarize the results.
After running wait_time_scheduler.py, the results are saved in the folder result/wait_time.
- The file
result.txtstores the trimmed mean of the results for all models. - The subfolders named
{method}store the results of the 1,000 experiments for each individual model. - After running
wait_time_stats.py, a CSV file namedresult.csvwas generated to summarize the results of different methods.
The files flex_scheduler.py and flex_exp.py are used to analyze the flexibility of SPANE (Section V-C).
flex_exp.pyruns 1,000 experiments for a single model.flex_scheduler.pyis responsible for running these experiments in parallel.flex_stats.pyis used to summarize the results.
After running flex_scheduler.py, the results are saved in the folder result/flex.
- The file
result.txtstores the trimmed mean of the results for all models. - The subfolders named
{PM_num}store the results of the 1,000 experiments for each PM number. - After running
flex_stats.py, a CSV file namedresult.csvwas generated to summarize the results of different PM number.