In performance testing of the serving framework, counterintuitive phenomena often arise due to the opaque internal mechanism (black-box effect), such as decreased throughput when concurrency increases or significant performance discrepancies under identical configurations across different hardware platforms. The core value of the serving tuning tool msServiceProfiler lies in transforming the serving framework from "black-box" to "white-box" by providing full-link performance profiling, which clearly visualizes the performance throughout the serving scheduling process.
The tool provides the following in-depth profile data collection and parsing capabilities for the MindIE Motor inference service:
With comprehensive and visualized performance insights from msServiceProfiler, users can deeply understand the internal mechanism of the serving framework and thereby efficiently optimize performance.
The following describes how to use the tool.
The following provides only a quick start guide for the serving tuning tool. For details about the tool operations, APIs, parameters, and fields, see Serving Tuning Tool.
Install and configure MindIE by referring to MindIE Installation Guide and ensure that MindIE Motor can run properly.
The collection capability of msServiceProfiler needs to be enabled by setting the environment variable SERVICE_PROF_CONFIG_PATH before the MindIE Motor service is deployed. If the environment variable is misspelled or not set before deploying the MindIE Motor service, the msServiceProfiler collection capability cannot be enabled.
Run the following command to configure environment variables. The following uses the ms_service_profiler_config.json file as an example.
export SERVICE_PROF_CONFIG_PATH="./ms_service_profiler_config.json"
The value of SERVICE_PROF_CONFIG_PATH must point to the .json file name. The .json file is the configuration file for controlling profile data collection. For example, it specifies the path for storing profile metadata and enables or disables operator collection. For details about the fields, see 4. If no configuration file exists at the specified path, the tool automatically generates a default configuration (with the collection function disabled by default).
If the environment variables are correctly configured, the tool outputs the following logs starting with [msservice_profiler] before the service deployment is complete, indicating that msServiceProfiler has been started.
[msservice_profiler] [PID:225] [INFO] [ParseEnable:179] profile enable_: false [msservice_profiler] [PID:225] [INFO] [ParseAclTaskTime:264] profile enableAclTaskTime_: false [msservice_profiler] [PID:225] [INFO] [ParseAclTaskTime:265] profile msptiEnable_: false [msservice_profiler] [PID:225] [INFO] [LogDomainInfo:357] profile enableDomainFilter_: false
If the configuration file specified by SERVICE_PROF_CONFIG_PATH does not exist, the tool outputs logs that are automatically created. Using the configuration in 2 as an example, the tool outputs the following logs:
[msservice_profiler] [PID:225] [INFO] [SaveConfigToJsonFile:588] Successfully saved profiler configuration to: ./ms_service_profiler_config.json
After the MindIE Motor service is successfully deployed, you can precisely control collection behavior by modifying fields in the configuration file.
1 2 3 4 5 6 | { "enable": 1, "prof_dir": "${PATH}/prof_dir/", "acl_task_time": 0 ... # Only the three fields above are configured as an example. } |
Parameter |
Description |
Mandatory (Yes/No) |
|---|---|---|
enable |
Globally enables or disables profile data collection. The options are as follows:
If this parameter is set to 0, no data is collected even if other parameters enable their corresponding features. If only this parameter is set to 1, only serving profile data is collected. |
Yes |
prof_dir |
Path for storing the collected profile data. The default path is ${HOME}/.ms_server_profiler. This path stores the original profile data. Subsequent parsing steps are required to obtain visualized profile data files for analysis. When enable is 0, modification to prof_dir takes effect after enable is changed to 1. When enable is 1, modification to prof_dir does not take effect. |
No |
acl_task_time |
Enables or disables profiling for operator delivery time and execution time. The options are as follows:
NOTE:
|
No |
If enable retains the value of 1, the tool collects data from the moment the MindIE Motor inference service receives a request until the request ends. The size of the directory under prof_dir will continue to grow. Therefore, you are advised to collect data only during key time periods.
Whenever the enable field changes, the tool outputs corresponding logs to indicate the change.
[msservice_profiler] [PID:3259] [INFO] [DynamicControl:407] Profiler Enabled Successfully!
Or
[msservice_profiler] [PID:3057] [INFO] [DynamicControl:411] Profiler Disabled Successfully!
Whenever enable is changed from 0 to 1, all fields in the configuration file are reloaded by the tool, enabling dynamic updates.
python >= 3.10 pandas >= 2.2 numpy >= 1.24.3 psutil >= 5.9.5
python3 -m ms_service_profiler.parse --input-path=${PATH}/prof_dir
--input-path is the path specified by the prof_dir parameter in 4.
After parsing, the parsed profile data file is generated in the directory where the command is executed.
The parsed profile data can be in .db, .csv, or .json format. You can quickly analyze from different dimensions such as requests and scheduling using .csv files, or import .db or .json files into MindStudio Insight for visualized analysis. For detailed operations and analysis description, see "Service-oriented Tuning" in MindStudio Insight User Guide.