Serving Tuning Tool

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.

Procedure

  1. Set up the environment.

    Install and configure MindIE by referring to MindIE Installation Guide and ensure that MindIE Motor can run properly.

  2. Configure environment variables.

    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).

  3. Run the MindIE Motor service.

    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

  4. Profile data.

    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.
    }
    
    Table 1 Parameters

    Parameter

    Description

    Mandatory (Yes/No)

    enable

    Globally enables or disables profile data collection. The options are as follows:

    • 0: disabled
    • 1: enabled

    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:

    • 0: disabled. It is the default value. If this parameter is set to 0 or an invalid value, this function is disabled.
    • 1: enabled
    NOTE:
    • Enabling this function will occupy certain device performance, which may cause inaccurate profiling data. You are advised to enable this function when model execution is abnormal for further analysis.
    • Operator collection generates large amounts of data. You are advised to collect data for 3s to 5s. Longer collection time consumes additional disk space and increases parsing time, prolonging performance issue locating.
    • The default operator collection level is L0. To enable other operator collection levels, see the complete parameter description in Serving Tuning Tool.

    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.

  5. Parse data.

    1. Install environment dependencies.
      python >= 3.10
      pandas >= 2.2
      numpy >= 1.24.3
      psutil >= 5.9.5
    2. Run the parsing command.
      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.

  6. Perform tuning analysis.

    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.