我要评分
获取效率
正确性
完整性
易理解

Collecting Data During Runtime

The K-NET data collection and analysis tool packages tracelib-collector-aarch64.tar.gz and tracelib-collector-x86_64.tar.gz are available on Kunpeng and x86 servers, respectively. After the packages are decompressed, the dynamic library librecord.so is generated in the decompression directory. This dynamic library is loaded through the LD_PRELOAD environment variable when applications are running, allowing it to collect POSIX function and parameter information.

  • The dynamic library is compatible with both x86 and Kunpeng architectures and requires Glibc 2.17 or later.
  • The tool does not collect variable parameter functions in common scenarios. For the variable parameter functions in the compatibility list, only the first three parameters (fcntl, fcntl64, and ioctl) required for compatibility analysis are collected.

Command Function

Collects POSIX functions and parameters during runtime.

Syntax

Executing librecord.so depends on the libglib-2.0.so and libgobject-2.0.so files distributed in the same package. Therefore, set LD_LIBRARY_PATH to include the directories of the two dynamic libraries. This setting prevents the "undefined symbol" error caused by the failure to find the dependent libraries.

LD_LIBRARY_PATH=/directory/of/:$LD_LIBRARY_PATH LD_PRELOAD=/path/to/librecord.so [Environment variable 1=Argument 1] ... [Environment variable n=Argument n] executable args

To collect runtime data, you need to specify the dynamic library path, configure environment variables, and the path to the binary file to be collected. You can configure one or more environment variables, among which RECORD_CONF is mandatory. Separate multiple environment variables using spaces.

  • /directory/of/: directory where librecord.so, libglib-2.0.so, and libgobject-2.0.so are located.
  • /path/to/: full path that contains librecord.so.
  • executable: Mandatory. Replace it with the actual path to the binary file to be collected.
  • args: Replace it with the argument required by the binary file.

Parameter Description

Table 1 Environment variables

Environment Variable

Data Type

Description

RECORD_CONF

str

Configuration file, which specifies the path to the configuration file of the POSIX functions to be recorded. This parameter is mandatory.

Even when the pthread_create and fork functions are not specified in the configuration file, the two functions are still collected by default.

RECORD_OUT_DIR

str

Data file output directory. This parameter is optional. If this parameter is not set, the record.data folder is created in the current directory.

POSIX function information is collected based on the configuration file specified by RECORD_CONF. The collected data is stored in the output directory specified by RECORD_OUT_DIR. Data of different thread IDs is stored in different files.

RECORD_VERBOSE

int

Indicates whether to print log information. The default value is 0. This parameter is optional.

  • 1: prints logs.
  • 0: does not print logs.

RECORD_FUNC_LIMIT

int

Maximum number of records for each function in a single thread ID. If this parameter is not specified, the maximum number of records is 2^31-1. This parameter is optional.

RECORD_TIMEOUT

int

Collection timeout duration, in seconds. If this parameter is not specified, it is 2^63-1 seconds. This parameter is optional.

The program automatically exits after the specified period. The data already collected will be retained.

Configuration File Description

The configuration file specified by RECORD_CONF is in the following format:

pthread_create 1
fork 1
socket 1
bind 0 

Each line in the configuration file contains only two columns. The first column is the POSIX function name. The second column indicates whether to (0 or 1) record the parameter of the called function. Spaces are used as separators.

Storage of Collected Data Files

Data of different threads is stored in different files whose names are record.TID. These collected data files are in the following format:

1 36149310 3081497 3081497 3081504 3081497 2740656
2 35935130 3081504 3081497
0 36206400 socket 3 2 1 0
0 36251390 connect 3 4 281474441245944 16
0 36345270 write 3 1 745149072 27
0 36374000 write 3 1 745149072 23
0 36400280 write 3 1 745149072 36
0 36419820 write 3 1 745149072 35

Each line in the data file indicates a data packet. The first digit of a data packet indicates the data packet type:

  • 0: Function information.
    The number of parameters and whether parameter data is recorded depend on the configuration file. Spaces are used as separators. The parameters in this type of data packet are used for subsequent compatibility analysis. The timestamp and function name are used for drawing sequence diagrams.
     0 <timestamp> <function name> [<number of parameters> <parameter data> ...]
  • 1: process information
    Information such as process IDs in data packets of this type is mainly used to represent the relationship between processes during the creation of a sequence diagram. Spaces are used as separators.
     1 <timestamp> <process ID> <process group ID> <thread ID> <thread group ID> <parent process ID>
  • 2: thread creation information
    Information such as thread IDs in data packets of this type is mainly used to represent the relationship between threads during the creation of a sequence diagram. Spaces are used as separators.
    2 <timestamp> <current thread ID> <parent thread ID>