> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 性能调优与优化入门

您可以使用性能构建版本来测量系统性能。此外，您还可以编译调试工具来分析和解决任何性能问题。

## **前提条件**

要开始使用 Qualcomm<sup>®</sup> Linux<sup>®</sup> 开发您的软件，请按照[使用 Yocto 构建 Qualcomm Linux](https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/build-qualcomm-linux) 中的说明设置您的基础设施。该构建指南还介绍了常见的构建工作流。

## **性能分析和调优流程工作流**

下图显示了实现预期系统性能的工作流：

<div className="flex flex-col items-center gap-2">
  <img src="https://mintcdn.com/qualcomm-staging/uWQLnBcS9sxlZhgB/System/Performance/media/k2l-performance/qual_linux_perform_workflow.svg?fit=max&auto=format&n=uWQLnBcS9sxlZhgB&q=85&s=2746310c37826b8f034a95869856ae0d" alt="图：测量 Qualcomm Linux 系统性能的工作流" width="1210" height="310" data-path="System/Performance/media/k2l-performance/qual_linux_perform_workflow.svg" />

  <p className="text-sm text-gray-700">
    图：测量 Qualcomm Linux 系统性能的工作流
  </p>
</div>

该工作流图将性能分析和调优过程总结为六个步骤：

1. 使用分析工具准备性能构建版本。
2. 测量关键性能指标（KPI），例如系统基准测试和引导时间。
3. 排查性能问题，包括 CPU 工作负载和内存使用情况。
4. 应用调优和定制以解决已识别的问题。
5. 评估 KPI 目标以确定是否达到性能目标。如果未达到性能目标，请根据系统需求进行故障排查和调优。这形成了持续性能改进的迭代循环。
6. 在 [Qualcomm 支持](https://www.qualcomm.com/support/)报告未解决的问题。

## **准备性能构建版本**

建议使用性能构建版本进行性能测量或调试。要准备性能构建版本，请使用以下命令：

```text theme={null}
kas build meta-qcom/ci/<machine>.yml:meta-qcom/ci/qcom-distro.yml:meta-qcom/ci/performance.yml
```

将 `<machine>` 替换为您的目标机器名称，例如 `qcs6490-rb3gen2-core-kit.yml`。

有关更多信息，请参阅[使用 Yocto 构建 Qualcomm Linux](https://dragonwingdocs.qualcomm.com/Key-Documents/Yocto-Guide/build-qualcomm-linux)。

性能构建版本使用源代码中的以下内核配置片段：

`meta-qcom/recipes-kernel/linux/linux-qcom-6.18/configs/bsp-additions.cfg`

这些内核配置在源代码内核配方中定义，位于

`meta-qcom/recipes-kernel/linux/linux-qcom_6.18.bb`

## **编译性能工具**

用于调试性能问题的工具包括 LTTng、GCC、G++、htop、perf 实用程序、iotop 和 lmbench。

要编译调试工具，请将它们添加到源代码中以下路径的 `qcom-multimedia-image.bb` 发行版镜像中：

`meta-qcom-distro/recipes-products/images/`

```text theme={null}
diff --git a/recipes-products/images/qcom-multimedia-image.bb b/recipes-products/images/qcom-multimedia-image.bb
index 23a2f40..5295bf9 100644
--- a/recipes-products/images/qcom-multimedia-image.bb
+++ b/recipes-products/images/qcom-multimedia-image.bb
@@ -10,4 +10,20 @@ REQUIRED_DISTRO_FEATURES += "wayland"
CORE_IMAGE_BASE_INSTALL += " \
      packagegroup-qcom-multimedia \
      packagegroup-qcom-iot-base-utils \
+     lttng-tools \
+     lttng-tools-dev \
+     lttng-modules \
+     lttng-modules-dev \
+     lttng-ust \
+     lttng-ust-dev \
+     liburcu-dev \
+     gcc \
+     g++ \
+     iotop \
+     htop \
+     perf \
+     lmbench \
"
```

要应用此补丁，请从 `meta-qcom-distro` 目录运行 `git apply <patch-file>`，或手动将列出的软件包添加到配方文件中。

## **后续步骤**

* [影响性能的功能](./features-impacting-performance)
