---
title: 访存统计分析
description: "基于CPU访问缓存和内存的PMU事件，分析存储的访问次数、命中率、带宽等相关情况。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/devkit_24_rc2/cliuserguide/KunpengDevKitCli_0066.html
sourcePath: /source/zh/kunpengdevkithistory/devkit_24_rc2/cliuserguide/KunpengDevKitCli_0066.html
indexId: a33b000c5647a3f7d223237728c8da14af90f26613aa06e5383b0decbc9e9e0785
---
# 访存统计分析

#### 命令功能

基于CPU访问缓存和内存的PMU事件，分析存储的访问次数、命中率、带宽等相关情况。


#### 命令格式

```
devkit tuner memory [-h] [-d <sec>] [-l {0, 1, 2, 3}] [-i <sec>] [-o] [-m {1, 2, 3}] [-p {100, 1000}] [-c {n,m | n-m}] [--package]
```


#### 参数说明


**表1 参数说明**

| 参数 | 参数选项 | 说明 |
| --- | --- | --- |
| \-h/\-\-help | \- | 获取帮助信息。 |
| \-d/\-\-duration | \- | 设置采集时长，单位为秒，默认为30秒，可配置范围1\-300秒，可使用Ctrl+\取消任务或Ctrl+C停止采集并进入分析。 |
| \-l/\-\-log\-level | 0/1/2/3 | 配置日志等级。默认值为1(info)。 0(debug) 1(info) 2(warning) 3(error) |
| \-i/\-\-interval | \- | 设置任务的采集间隔（以秒为单位）。最小值为1秒，最大值不能超过采集时长。默认为持续时间。如果不指定间隔，不生成子报告。每个子报告中收集数据的时间取决于间隔参数。 |
| \-m/\-\-metric | 1/2/3 | 设置采样类型，默认为1（ALL）。 1（ALL）全部 2（Cache）缓存访问 3（DDR）DDR访问 |
| \-o/\-\-output | \- | 设置报告数据压缩包名称和输出路径，仅输入名称时默认生成在当前所在目录；需和\-\-package配合使用。 |
| \-c/\-\-cpu | \- | 指定采集的CPU核数，如“0”、“0,1,2”、“0\-2”。默认采集所有CPU核。 |
| \-p/\-\-period | 100/1000 | 设置数据的采集间隔。默认为1000毫秒，可选100毫秒和1000毫秒；若采集时长选择1秒，采集间隔的默认值将自动调整为100毫秒。 |
| \-\-package | \- | 设置是否生成报告数据压缩包，不指定压缩包名称和路径时默认在当前所在目录生成memory\-时间戳.tar。 |


#### 使用示例

```
devkit tuner memory -d 2 -o /home/memory_result -m 1 --package
```

命令参数-d为采集时长3秒，参数-o /home/memory_result和--package生成以memory_result命名的报告数据压缩包至指定路径，参数-m 1为采集所有缓存和DDR访问数据。


返回信息如下：

```
Memory Summary Report-ALL                               Time:2024/06/12 09:32:27
================================================================================
System Information
────────────────────────────────────────────────────────────────────
Linux Kernel Version        5.10.0-153.46.0.124.oe2203sp2.aarch64
Cpu Type                    920
NUMA NODE                   0         1         2         3
cpus                        0-31      32-63     64-95     96-127
Percentage of core Cache miss
────────────────────────────────────────────────────────────────────
L1D         1.33%
L1I         1.79%
L2D        28.63%
L2I        32.84%
DDR Bandwidth
────────────────────────────────────────────────────────────────────
ddrc_write        25.92MB/s
ddrc_read         53.76MB/s
Memory metrics of the Cache
────────────────────────────────────────────────────────────────────
1. L1/L2/TLB Access Bandwidth and Hit Rate
Value Format: X|Y = Bandwidth | Hit Rate
────────────────────────────────────────────────────────────────────
CPU                   L1D                   L1I                  L2D                 L2I       L2D_TLB       L2I_TLB
────────────────────────────────────────────────────────────────────
all    1660.18MB/s|98.67%    2800.42MB/s|98.21%    375.66MB/s|71.37%    74.38MB/s|67.16%    N/A|99.38%    N/A|98.85%
────────────────────────────────────────────────────────────────────
2. L3 Read Bandwidth and Hit Rate
─────────────────────────────────────────────────────────────────
NODE    Read Hit Bandwidth    Read Bandwidth    Read Hit Rate
─────────────────────────────────────────────────────────────────
0                 2.50MB/s         17.70MB/s           14.13%
1                 5.82MB/s         36.51MB/s           15.95%
2                 1.80MB/s         14.00MB/s           12.84%
3                14.40MB/s         48.97MB/s           29.41%
─────────────────────────────────────────────────────────────────
Memory metrics of the DDRC
────────────────────────────────────────────────────────────────────
1. DDRC_ACCESS_BANDWIDTH
Value Format: X|Y = DDR read | DDR write
────────────────────────────────────────────────────────────────────
NUMANODE               DDRC_0                 DDRC_1               DDRC_2                DDRC_3                   Total
────────────────────────────────────────────────────────────────────
0           0.00MB/s|0.00MB/s    38.25MB/s|14.04MB/s    0.00MB/s|0.00MB/s     0.00MB/s| 0.00MB/s    38.25MB/s|14.04MB/s
1           0.00MB/s|0.00MB/s     0.00MB/s| 0.00MB/s    0.00MB/s|0.00MB/s    29.39MB/s| 8.99MB/s    29.39MB/s| 8.99MB/s
2           0.00MB/s|0.00MB/s     0.00MB/s| 0.00MB/s    0.00MB/s|0.00MB/s    47.16MB/s|17.61MB/s    47.16MB/s|17.61MB/s
3           0.00MB/s|0.00MB/s    20.47MB/s| 6.70MB/s    0.00MB/s|0.00MB/s     0.00MB/s| 0.00MB/s    20.47MB/s| 6.70MB/s
────────────────────────────────────────────────────────────────────
2. DDRC_ACCESS_COUNT
Value Format: X|Y = read | write
────────────────────────────────────────────────────────────────────
NUMANODE                Local            Cross-die          Cross-chip                 Total
────────────────────────────────────────────────────────────────────
0          100,618/s|43,789/s     51,320/s| 5,751/s     5,655/s|1,790/s    157,593/s|51,330/s
1          117,402/s|50,205/s    151,277/s|15,257/s    19,498/s|2,036/s    288,178/s|67,499/s
2          235,676/s|74,314/s     64,373/s| 5,972/s    31,126/s|3,295/s    331,176/s|83,582/s
3           27,753/s|18,038/s     19,332/s| 4,174/s     4,161/s|1,579/s     51,247/s|23,791/s
────────────────────────────────────────────────────────────────────
The report /home/memory_result.tar is generated successfully.
To view summary report. you can run: devkit report -i /home/memory_result.tar
To view detail report. you can import the report to the WebUI or IDE to view details.
```
