Parsing Profile Data

Before parsing profile data, you need to collect the raw data.

  1. Log in as the running user to the development environment where the CANN Toolkit package and ops operator package are located.
  2. Switch to the directory where the msprof.py script is located.

    ${INSTALL_DIR}/tools/profiler/profiler_tool/analysis/msprof. Replace ${INSTALL_DIR} with the actual CANN component directory. If the Ascend-CANN-Toolkit package is installed as the root user, the CANN component directory is /usr/local/Ascend/ascend-toolkit/latest.

  3. Parse the profile data.

    The command syntax is as follows:

    python3 msprof.py import -dir <dir>

    Example: python3 msprof.py import -dir /home/HwHiAiUser/profiler_data/PROF_XXX

    Table 1 Parsing command options

    Option

    Description

    Required/Optional

    import

    Parse profile data in import mode.

    When the profile data is parsed in the import mode, a .db file is generated even if there is an existing .db file in the original profile data directory.

    Required

    --cluster

    Parses and summarizes profile data in the cluster scenario. This option is supported only when the import parameter is configured.

    The -dir parameter specifies the parent directory of PROF_XXX. The parsing result is stored in the sqlite directory generated under PROF_XXX.

    This option is mandatory in the cluster scenario.

    -dir or --collection-dir

    Directory of collected profile data. The value must be the parent directory of the PROF_XXX or PROF_XXX directory, for example,

    /home/HwHiAiUser/profiler_data/PROF_XXX

    Required

    -h or --help

    Help information.

    Optional

    After the commands are executed, the sqlite directory is generated in the device_{id}and host directories of PROF_XXX. A .db file is generated in the sqlite directory. The .db file is the intermediate result and can be ignored. You can perform 4 to export the final .db file.

  4. (Optional) Parse the .db file for the second time.

    This function further parses the .db file in the sqlite directory and generates a .db file (msprof_timestamp.db) that summarizes all profile data.

    python3 msprof.py export db -dir <dir> 
    • During the execution of the export db command, a .db file (msprof_timestamp.db) that summarizes all profile data is generated in the PROF_XXX directory. You can view the file through MindStudio Insight.
    • When the msprof command is used to profile data, this API is automatically called to generate a .db file (msprof_timestamp.db) that summarizes all profile data. In normal cases, you do not need to manually perform this step.