Creating a performance profile

Learn about the Performance Profile Creator (PPC) and how you can use it to create a performance profile.

About the Performance Profile Creator

The Performance Profile Creator (PPC) is a command-line tool, delivered with the Performance Addon Operator, used to create the performance profile. The tool consumes must-gather data from the cluster and several user-supplied profile arguments. The PPC generates a performance profile that is appropriate for your hardware and topology.

The tool is run by one of the following methods:

  • Invoking podman

  • Calling a wrapper script

Gathering data about your cluster using must-gather

The Performance Profile Creator (PPC) tool requires must-gather data. As a cluster administrator, run must-gather to capture information about your cluster.

Prerequisites

  • Access to the cluster as a user with the cluster-admin role.

  • Access to the Performance Addon Operator image.

  • The OpenShift CLI (oc) installed.

Procedure

  1. Navigate to the directory where you want to store the must-gather data.

  2. Run must-gather on your cluster:

    1. $ oc adm must-gather --image=<PAO_image> --dest-dir=<dir>

    must-gather must be run with the performance-addon-operator-must-gather image. The output can optionally be compressed. Compressed output is required if you are running the Performance Profile Creator wrapper script.

    Example

    1. $ oc adm must-gather --image=quay.io/openshift-kni/performance-addon-operator-must-gather:4.8-snapshot --dest-dir=must-gather
  3. Create a compressed file from the must-gather directory:

    1. $ tar cvaf must-gather.tar.gz must-gather/

Running the Performance Profile Creator using podman

As a cluster administrator, you can run podman and the Performance Profile Creator to create a performance profile.

Prerequisites

  • Access to the cluster as a user with the cluster-admin role.

  • A cluster installed on bare metal hardware.

  • A node with podman and OpenShift CLI (oc) installed.

Procedure

  1. Check the machine config pool:

    1. $ oc get mcp

    Example output

    1. NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE
    2. master rendered-master-acd1358917e9f98cbdb599aea622d78b True False False 3 3 3 0 22h
    3. worker-cnf rendered-worker-cnf-1d871ac76e1951d32b2fe92369879826 False True False 2 1 1 0 22h
  2. Optional: Display help for the PPC tool:

    1. $ podman run --entrypoint performance-profile-creator quay.io/openshift-kni/performance-addon-operator:4.8-snapshot -h

    Example output

    1. A tool that automates creation of Performance Profiles
    2. Usage:
    3. performance-profile-creator [flags]
    4. Flags:
    5. --disable-ht Disable Hyperthreading
    6. -h, --help help for performance-profile-creator
    7. --info string Show cluster information; requires --must-gather-dir-path, ignore the other arguments. [Valid values: log, json] (default "log")
    8. --mcp-name string MCP name corresponding to the target machines (required)
    9. --must-gather-dir-path string Must gather directory path (default "must-gather")
    10. --power-consumption-mode string The power consumption mode. [Valid values: default, low-latency, ultra-low-latency] (default "default")
    11. --profile-name string Name of the performance profile to be created (default "performance")
    12. --reserved-cpu-count int Number of reserved CPUs (required)
    13. --rt-kernel Enable Real Time Kernel (required)
    14. --split-reserved-cpus-across-numa Split the Reserved CPUs across NUMA nodes
    15. --topology-manager-policy string Kubelet Topology Manager Policy of the performance profile to be created. [Valid values: single-numa-node, best-effort, restricted] (default "restricted")
    16. --user-level-networking Run with User level Networking(DPDK) enabled
  3. Run the Performance Profile Creator tool in discovery mode:

    Discovery mode inspects your cluster using the output from must-gather. The output produced includes information on:

    • The NUMA cell partitioning with the allocated CPU ids

    • Whether hyperthreading is enabled

    Using this information you can set appropriate values for some of the arguments supplied to the Performance Profile Creator tool.

    1. $ podman run --entrypoint performance-profile-creator -v /must-gather:/must-gather:z quay.io/openshift-kni/performance-addon-operator:4.8-snapshot --info log --must-gather-dir-path /must-gather

    This command uses the performance profile creator as a new entry point to podman. It maps the must-gather data for the host into the container image and invokes the required user-supplied profile arguments to produce the my-performance-profile.yaml file.

    The -v option can be the path to either:

    • The must-gather output directory

    • An existing directory containing the must-gather decompressed tarball

    The info option requires a value which specifies the output format. Possible values are log and JSON. The JSON format is reserved for debugging.

  4. Run podman:

    1. $ podman run --entrypoint performance-profile-creator -v /must-gather:/must-gather:z quay.io/openshift-kni/performance-addon-operator:4.8-snapshot --mcp-name=worker-cnf --reserved-cpu-count=20 --rt-kernel=true --split-reserved-cpus-across-numa=false --topology-manager-policy=single-numa-node --must-gather-dir-path /must-gather --power-consumption-mode=ultra-low-latency > my-performance-profile.yaml

    The Performance Profile Creator arguments are shown in the Performance Profile Creator arguments table. The following arguments are required:

    • reserved-cpu-count

    • mcp-name

    • rt-kernel

    The mcp-name argument in this example is set to worker-cnf based on the output of the command oc get mcp. For Single Node OpenShift (SNO) use —mcp-name=master.

  5. Review the created YAML file:

    1. $ cat my-performance-profile.yaml

    Example output

    1. apiVersion: performance.openshift.io/v2
    2. kind: PerformanceProfile
    3. metadata:
    4. name: performance
    5. spec:
    6. additionalKernelArgs:
    7. - nmi_watchdog=0
    8. - audit=0
    9. - mce=off
    10. - processor.max_cstate=1
    11. - intel_idle.max_cstate=0
    12. - idle=poll
    13. cpu:
    14. isolated: 1,3,5,7,9,11,13,15,17,19-39,41,43,45,47,49,51,53,55,57,59-79
    15. reserved: 0,2,4,6,8,10,12,14,16,18,40,42,44,46,48,50,52,54,56,58
    16. nodeSelector:
    17. node-role.kubernetes.io/worker-cnf: ""
    18. numa:
    19. topologyPolicy: single-numa-node
    20. realTimeKernel:
    21. enabled: true
  6. Apply the generated profile:

    1. $ oc apply -f my-performance-profile.yaml

How to run podman to create a performance profile

The following example illustrates how to run podman to create a performance profile with 20 reserved CPUs that are to be split across the NUMA nodes.

Node hardware configuration:

  • 80 CPUs

  • Hyperthreading enabled

  • Two NUMA nodes

  • Even numbered CPUs run on NUMA node 0 and odd numbered CPUs run on NUMA node 1

Run podman to create the performance profile:

  1. $ podman run --entrypoint performance-profile-creator -v /must-gather:/must-gather:z quay.io/openshift-kni/performance-addon-operator:4.8-snapshot --mcp-name=worker-cnf --reserved-cpu-count=20 --rt-kernel=true --split-reserved-cpus-across-numa=true --must-gather-dir-path /must-gather > my-performance-profile.yaml

The created profile is described in the following YAML:

  1. apiVersion: performance.openshift.io/v2
  2. kind: PerformanceProfile
  3. metadata:
  4. name: performance
  5. spec:
  6. cpu:
  7. isolated: 10-39,50-79
  8. reserved: 0-9,40-49
  9. nodeSelector:
  10. node-role.kubernetes.io/worker-cnf: ""
  11. numa:
  12. topologyPolicy: restricted
  13. realTimeKernel:
  14. enabled: true

In this case, 10 CPUs are reserved on NUMA node 0 and 10 are reserved on NUMA node 1.

Running the Performance Profile Creator wrapper script

The performance profile wrapper script simplifies the running of the Performance Profile Creator (PPC) tool. It hides the complexities associated with running podman and specifying the mapping directories and it enables the creation of the performance profile.

Prerequisites

  • Access to the Performance Addon Operator image.

  • Access to the must-gather tarball.

Procedure

  1. Create a file on your local machine named, for example, run-perf-profile-creator.sh:

    1. $ vi run-perf-profile-creator.sh
  2. Paste the following code into the file:

    1. #!/bin/bash
    2. readonly CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-podman}
    3. readonly CURRENT_SCRIPT=$(basename "$0")
    4. readonly CMD="${CONTAINER_RUNTIME} run --entrypoint performance-profile-creator"
    5. readonly IMG_EXISTS_CMD="${CONTAINER_RUNTIME} image exists"
    6. readonly IMG_PULL_CMD="${CONTAINER_RUNTIME} image pull"
    7. readonly MUST_GATHER_VOL="/must-gather"
    8. PAO_IMG="quay.io/openshift-kni/performance-addon-operator:4.8-snapshot"
    9. MG_TARBALL=""
    10. DATA_DIR=""
    11. usage() {
    12. print "Wrapper usage:"
    13. print " ${CURRENT_SCRIPT} [-h] [-p image][-t path] -- [performance-profile-creator flags]"
    14. print ""
    15. print "Options:"
    16. print " -h help for ${CURRENT_SCRIPT}"
    17. print " -p Performance Addon Operator image"
    18. print " -t path to a must-gather tarball"
    19. ${IMG_EXISTS_CMD} "${PAO_IMG}" && ${CMD} "${PAO_IMG}" -h
    20. }
    21. function cleanup {
    22. [ -d "${DATA_DIR}" ] && rm -rf "${DATA_DIR}"
    23. }
    24. trap cleanup EXIT
    25. exit_error() {
    26. print "error: $*"
    27. usage
    28. exit 1
    29. }
    30. print() {
    31. echo "$*" >&2
    32. }
    33. check_requirements() {
    34. ${IMG_EXISTS_CMD} "${PAO_IMG}" || ${IMG_PULL_CMD} "${PAO_IMG}" || \
    35. exit_error "Performance Addon Operator image not found"
    36. [ -n "${MG_TARBALL}" ] || exit_error "Must-gather tarball file path is mandatory"
    37. [ -f "${MG_TARBALL}" ] || exit_error "Must-gather tarball file not found"
    38. DATA_DIR=$(mktemp -d -t "${CURRENT_SCRIPT}XXXX") || exit_error "Cannot create the data directory"
    39. tar -zxf "${MG_TARBALL}" --directory "${DATA_DIR}" || exit_error "Cannot decompress the must-gather tarball"
    40. chmod a+rx "${DATA_DIR}"
    41. return 0
    42. }
    43. main() {
    44. while getopts ':hp:t:' OPT; do
    45. case "${OPT}" in
    46. h)
    47. usage
    48. exit 0
    49. ;;
    50. p)
    51. PAO_IMG="${OPTARG}"
    52. ;;
    53. t)
    54. MG_TARBALL="${OPTARG}"
    55. ;;
    56. ?)
    57. exit_error "invalid argument: ${OPTARG}"
    58. ;;
    59. esac
    60. done
    61. shift $((OPTIND - 1))
    62. check_requirements || exit 1
    63. ${CMD} -v "${DATA_DIR}:${MUST_GATHER_VOL}:z" "${PAO_IMG}" "$@" --must-gather-dir-path "${MUST_GATHER_VOL}"
    64. echo "" 1>&2
    65. }
    66. main "$@"
  3. Add execute permissions for everyone on this script:

    1. $ chmod a+x run-perf-profile-creator.sh
  4. Optional: Display the run-perf-profile-creator.sh command usage:

    1. $ ./run-perf-profile-creator.sh -h

    Expected output

    1. Wrapper usage:
    2. run-perf-profile-creator.sh [-h] [-p image][-t path] -- [performance-profile-creator flags]
    3. Options:
    4. -h help for run-perf-profile-creator.sh
    5. -p Performance Addon Operator image (1)
    6. -t path to a must-gather tarball (2)
    7. A tool that automates creation of Performance Profiles
    8. Usage:
    9. performance-profile-creator [flags]
    10. Flags:
    11. --disable-ht Disable Hyperthreading
    12. -h, --help help for performance-profile-creator
    13. --info string Show cluster information; requires --must-gather-dir-path, ignore the other arguments. [Valid values: log, json] (default "log")
    14. --mcp-name string MCP name corresponding to the target machines (required)
    15. --must-gather-dir-path string Must gather directory path (default "must-gather")
    16. --power-consumption-mode string The power consumption mode. [Valid values: default, low-latency, ultra-low-latency] (default "default")
    17. --profile-name string Name of the performance profile to be created (default "performance")
    18. --reserved-cpu-count int Number of reserved CPUs (required)
    19. --rt-kernel Enable Real Time Kernel (required)
    20. --split-reserved-cpus-across-numa Split the Reserved CPUs across NUMA nodes
    21. --topology-manager-policy string Kubelet Topology Manager Policy of the performance profile to be created. [Valid values: single-numa-node, best-effort, restricted] (default "restricted")
    22. --user-level-networking Run with User level Networking(DPDK) enabled

    There two types of arguments:

    • Wrapper arguments namely -h, -p and -t

    • PPC arguments

    1Optional: Specify the Performance Addon Operator image. If not set, the default upstream image is used: quay.io/openshift-kni/performance-addon-operator:4.8-snapshot.
    2-t is a required wrapper script argument and specifies the path to a must-gather tarball.
  5. Run the performance profile creator tool in discovery mode:

    Discovery mode inspects your cluster using the output from must-gather. The output produced includes information on:

    • The NUMA cell partitioning with the allocated CPU IDs

    • Whether hyperthreading is enabled

    Using this information you can set appropriate values for some of the arguments supplied to the Performance Profile Creator tool.

    1. $ ./run-perf-profile-creator.sh -t /must-gather/must-gather.tar.gz -- --info=log

    The info option requires a value which specifies the output format. Possible values are log and JSON. The JSON format is reserved for debugging.

  6. Check the machine config pool:

    1. $ oc get mcp

    Example output

    1. NAME CONFIG UPDATED UPDATING DEGRADED MACHINECOUNT READYMACHINECOUNT UPDATEDMACHINECOUNT DEGRADEDMACHINECOUNT AGE
    2. master rendered-master-acd1358917e9f98cbdb599aea622d78b True False False 3 3 3 0 22h
    3. worker-cnf rendered-worker-cnf-1d871ac76e1951d32b2fe92369879826 False True False 2 1 1 0 22h
  7. Create a performance profile:

    1. $ ./run-perf-profile-creator.sh -t /must-gather/must-gather.tar.gz -- --mcp-name=worker-cnf --reserved-cpu-count=2 --rt-kernel=true > my-performance-profile.yaml

    The Performance Profile Creator arguments are shown in the Performance Profile Creator arguments table. The following arguments are required:

    • reserved-cpu-count

    • mcp-name

    • rt-kernel

    The mcp-name argument in this example is set to worker-cnf based on the output of the command oc get mcp. For Single Node OpenShift (SNO) use —mcp-name=master.

  8. Review the created YAML file:

    1. $ cat my-performance-profile.yaml

    Example output

    1. apiVersion: performance.openshift.io/v2
    2. kind: PerformanceProfile
    3. metadata:
    4. name: performance
    5. spec:
    6. cpu:
    7. isolated: 1-39,41-79
    8. reserved: 0,40
    9. nodeSelector:
    10. node-role.kubernetes.io/worker-cnf: ""
    11. numa:
    12. topologyPolicy: restricted
    13. realTimeKernel:
    14. enabled: false
  9. Apply the generated profile:

    1. $ oc apply -f my-performance-profile.yaml

Performance Profile Creator arguments

Table 1. Performance Profile Creator arguments
ArgumentDescription

disable-ht

Disable hyperthreading.

Possible values: true or false.

Default: false.

If this argument is set to true you should not disable hyperthreading in the BIOS. Disabling hyperthreading is accomplished with a kernel command line argument.

info

This captures cluster information and is used in discovery mode only. Discovery mode also requires the must-gather-dir-path argument. If any other arguments are set they are ignored.

Possible values:

  • log

  • JSON

    These options define the output format with the JSON format being reserved for debugging.

Default: log.

mcp-name

MCP name for example worker-cnf corresponding to the target machines. This parameter is required.

must-gather-dir-path

Must gather directory path. This parameter is required.

When the user runs the tool with the wrapper script must-gather is supplied by the script itself and the user must not specify it.

power-consumption-mode

The power consumption mode.

Possible values:

  • default

  • low-latency

  • ultra-low-latency

Default: default.

profile-name

Name of the performance profile to create. Default: performance.

reserved-cpu-count

Number of reserved CPUs. This parameter is required.

This must be a natural number. A value of 0 is not allowed.

rt-kernel

Enable real-time kernel. This parameter is required.

Possible values: true or false.

split-reserved-cpus-across-numa

Split the reserved CPUs across NUMA nodes.

Possible values: true or false.

Default: false.

topology-manager-policy

Kubelet Topology Manager policy of the performance profile to be created.

Possible values:

  • single-numa-node

  • best-effort

  • restricted

Default: restricted.

user-level-networking

Run with user level networking (DPDK) enabled.

Possible values: true or false.

Default: false.

Additional resources