Updated on 2024-07-02 GMT+08:00

Dynamic Acceleration

Preparations

Before dynamic acceleration, you need to perform two checks. Applications can be dynamically accelerated only when both conditions are met.

  1. Run the following command to check whether the binary file to be optimized can be located again:
    readelf -a application | grep .rela.text
    • If the binary file contains .rela.text, the file can be located again. In this case, the application can be optimized.

    • If the binary file does not contain .rela.text, to allow BOLT to re-arrange functions (in addition to re-arranging code within functions) in your program, you need to add --emit-relocs or -q to the final link step of your application.
  2. Run the hce-wae --check command to check whether an application supports dynamic acceleration.

    If 3 is displayed, dynamic acceleration is supported.

Procedure

In the following operations, the mysqld application in the /data/apps/mysql-8.0.28/bin directory is used as an example.

  1. Generate an instrumentation application and run it.
    1. Run the /data/hce-wae/dbo/gen_instrumentation /data/apps/mysql-8.0.28/bin/mysqld command to generate an instrumentation application.

      Command format: /data/hce-wae/dbo/gen_instrumentationApplication path

      The mysqld.inst instrumentation file is generated in the current directory.

    2. Run the instrumentation file to obtain the PID of the application process. In this example, the PID is 87042.

  2. Create a dynamic acceleration configuration file for mysqld.

    Each application to be optimized must have a configuration file. Workload Accelerator dynamically accelerates the application based on the configuration file.

    1. Run the following command to copy the default configuration file /data/hce-wae/config/mysqld.conf:
      [root@localhost]# cp /data/hce-wae/config/hce-wae-tmp.conf /data/hce-wae/config/mysqld.conf 
    2. Set the origin-exe field in the /data/hce-wae/config/mysqld.conf configuration file.
      origin-exe indicates the location of the application to be optimized. In this example, the location is /data/apps/mysql-8.0.28/bin/mysqld.
      [root@localhost]# vim /data/hce-wae/config/mysqld.conf 

  3. Use the configuration file and the PID to configure dynamic acceleration.

    Command format: hce-wae --conf [PID] [/path/to/config]

  4. Enable dynamic acceleration to optimize the instrumentation application.

    Command format: hce-wae --start [PID]

    You can view the optimization status from the --status parameter. If the status is Running, the process is being optimized. If the status is Finished, the process has been optimized.

    Command format: hce-wae --status [PID]

  5. Use the --snapshot parameter to generate an optimized .dbo binary snapshot file. In this example, the file is mysqld.dbo.

    The default snapshot path is /data/hce-wae/snapshot/. You can change the path in the configuration file as needed. You can use this snapshot file to run the application without repeated optimization.

  6. Terminate dynamic acceleration to stop application optimization.

    Command format: hce-wae --stop [PID]

CLI for Dynamic Acceleration

A CLI is provided for dynamic acceleration. Table 1 lists the supported commands.

Figure 1 Startup page of dynamic acceleration
Figure 2 Help page of dynamic acceleration
Table 1 CLI commands supported for dynamic acceleration

Command

How to Use

Description

list

list

Obtains the process information in the current environment, including the PID, PPID, and command information.

status

status <PID>

Queries ongoing dynamic acceleration tasks and their status. The following information is returned:

  • PID
  • Process name
  • Optimization count
  • Acceleration status (Initialized, DataCollecting, Optimizing, HotPatching, Done, or Failed)

check

check <PID>

Checks whether the current process supports static or dynamic acceleration and displays the text result.

show

show <PID>

Queries the process dependencies.

conf

conf <PID>

Configures the dynamic acceleration capability for the target process. After you run the command, configuration options are displayed in sequence. Configure the options as prompted.

start

start <PID>

Enables dynamic acceleration.

stop

stop <PID>

Stops dynamic acceleration.

snapshot

snapshot <PID>

Generates a dynamic acceleration snapshot.

quit

quit

Exits the CLI.

h/help

h/help

Shows help information.