Skip to content

Commit bef7235

Browse files
committed
ci: carry our own GPUGet cache TTL patch for the AMD exporter
The patch parses AMD_GPU_GET_CACHE_TTL once in cmd/exporter, keeps the upstream 15 s default, and threads the value through the existing exporter and gpuagent options. It replaces the copy of functionstackx/device-metrics-exporter#1. 中文:补丁改为在 cmd/exporter 解析一次 AMD_GPU_GET_CACHE_TTL,保持上游 15 s 默认值,并沿既有的 exporter 与 gpuagent options 传递;取代此前复制自 functionstackx/device-metrics-exporter#1 的版本。
1 parent f08003a commit bef7235

4 files changed

Lines changed: 270 additions & 202 deletions

File tree

‎.github/workflows/amd-exporter-image.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
timeout-minutes: 30
2525
env:
2626
SOURCE_SHA: 9d0eb8c88af99f1dbe2914d803382092671456d9
27-
PATCH_SHA256: 66dbfab64d2ba4d04b762612fa1b3cbf6a54e5422c1c9e88eb02523eea2e0261
27+
PATCH_SHA256: b0bb7d3477be7ff5b3b455d17f83c454d3aae96ac8bf2e289306d3fd3df0e7a5
2828
GPU_AGENT_SHA: bcae57f9b395363f3340ad0b7393659b7df13f37
2929
ARCHIVE_NAME: device-metrics-exporter-v1.5.4-10.2.0a20261001.tar.gz
3030
ARCHIVE_SHA256: 0ba397bc31abc1c538e24f8d7264fb421cc5fb8dd59b2e1c493a8efec404c2ba
@@ -69,7 +69,8 @@ jobs:
6969
git -C exporter-source apply "$GITHUB_WORKSPACE/tools/amd-exporter/cache.patch"
7070
python3 -m unittest discover -s tools/amd-exporter -p 'test_*.py' -v
7171
cd exporter-source
72-
go test -race ./pkg/amdgpu/gpuagent -run 'Test(ParseGPUGetCacheTTL|GPUGetCache|DefaultGPUGet)' -count=1
72+
go test -race ./pkg/amdgpu/gpuagent -run 'Test(ParseGPUGetCacheTTL|CacheRead(HonorsGPUGetCacheTTL|ErrorClearsSlot|ConcurrentTTL)|NewAgentGPUGetCacheTTL)' -count=1
73+
go test ./pkg/exporter -run TestExporterOptions -count=1
7374
go test ./pkg/exporter/utils
7475
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -C cmd/exporter -trimpath \
7576
-ldflags "-X main.Version=1.5.4-powerx-cache -X main.GitCommit=$SOURCE_SHA+patch.$PATCH_SHA256 -X main.ROCmCommit=unknown" \

‎tools/amd-exporter/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The CPU-only `AMD exporter image` workflow builds a fresh-sample exporter and publishes a unique tag to `ghcr.io/semianalysisai/amd-device-metrics-exporter`. It does not start a GPU benchmark or change production data.
66

7-
The official ROCm nightly artifact from run `36867107435` has been deleted upstream. Reuse the retained Enroot conversion from InferenceX run `36985488002`, artifact `11217112734`, verified against squash SHA256 `0f2cbb4e2c41c1506db74c6653ea09ec5e7d42236d9532e2bc38fb9e0be5879e` and its original provenance. It contains source `9d0eb8c88af99f1dbe2914d803382092671456d9`. The runtime includes the upstream 255 W sentinel correction. `cache.patch` applies the configurable GPUGet cache change from [functionstackx/device-metrics-exporter#1](https://github.com/functionstackx/device-metrics-exporter/pull/1), with a default-cache regression and concurrent zero-cache tests.
7+
The official ROCm nightly artifact from run `36867107435` has been deleted upstream. Reuse the retained Enroot conversion from InferenceX run `36985488002`, artifact `11217112734`, verified against squash SHA256 `0f2cbb4e2c41c1506db74c6653ea09ec5e7d42236d9532e2bc38fb9e0be5879e` and its original provenance. It contains source `9d0eb8c88af99f1dbe2914d803382092671456d9`. The runtime includes the upstream 255 W sentinel correction. `cache.patch` makes the exporter's GPUGet response-cache TTL a startup setting, `AMD_GPU_GET_CACHE_TTL`: `cmd/exporter/main.go` parses it once and fails fast on a bad value, the exporter and gpuagent options carry it the same way `exit-on-agent-down` travels, and `cacheRead` applies it. Unset keeps the upstream 15 s cache, so the patch changes nothing unless the variable is set; `0s` makes every scrape issue a new GPUGet. The locking, query timeout and error handling around the cache are untouched. Its tests cover the parser, the cache decision at 15 s, 1 s and 0 s, the error path, sixteen concurrent readers at `0s`, and the exporter and agent defaults. `0s` is the only value that guarantees a fresh read per scrape: the cache timestamp is taken after GPUGet returns, so any positive TTL serves cached data on some scrapes. Each read holds the cache lock for the duration of its RPC, which the one-hour MI355X run tolerated at a 1.01 s worst gap. It replaces the earlier copy of [functionstackx/device-metrics-exporter#1](https://github.com/functionstackx/device-metrics-exporter/pull/1), which read the variable twice and changed the default to 1 s.
88

99
`base-runtime.json` records the original Docker configuration and hashes/symlink targets for 61 critical paths, extracted from the retained official OCI archive. Recovery verifies GPUAgent, entrypoint, AMD-SMI, ROCm sysdeps and companion binaries before importing the root filesystem with the original environment, entrypoint, labels and working directory. Enroot flattened layers, normalized ownership/permissions and generated its `/etc` startup files; the reconstructed base has a new identity and is not the original OCI image. Only `/home/amd/bin/server` is replaced in the subsequent overlay. `AMD_GPU_GET_CACHE_TTL=0s` forces each exporter request to issue a new GPUGet RPC. This removes exporter response reuse; actual hardware freshness, overhead and one-second benchmark collection still require live validation.
1010

‎tools/amd-exporter/README_zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
仅使用 CPU 的 `AMD exporter image` 工作流构建可获取新读数的 exporter,并向 `ghcr.io/semianalysisai/amd-device-metrics-exporter` 发布唯一标签。它不启动 GPU 基准测试,也不修改生产数据。
66

7-
官方 ROCm nightly 工作流 `36867107435` 的原始产物已被上游删除。现在复用 InferenceX 工作流 `36985488002` 保留的 Enroot 转换产物 `11217112734`,校验 squash SHA256 `0f2cbb4e2c41c1506db74c6653ea09ec5e7d42236d9532e2bc38fb9e0be5879e` 及原始来源回执。其源码为 `9d0eb8c88af99f1dbe2914d803382092671456d9`。该运行时包含上游 255 W 哨兵值修复。`cache.patch` 基于 [functionstackx/device-metrics-exporter#1](https://github.com/functionstackx/device-metrics-exporter/pull/1) 的可配置 GPUGet 缓存修改,并补充默认缓存回归测试和零缓存并发测试。
7+
官方 ROCm nightly 工作流 `36867107435` 的原始产物已被上游删除。现在复用 InferenceX 工作流 `36985488002` 保留的 Enroot 转换产物 `11217112734`,校验 squash SHA256 `0f2cbb4e2c41c1506db74c6653ea09ec5e7d42236d9532e2bc38fb9e0be5879e` 及原始来源回执。其源码为 `9d0eb8c88af99f1dbe2914d803382092671456d9`。该运行时包含上游 255 W 哨兵值修复。`cache.patch` 把 exporter 的 GPUGet 响应缓存 TTL 变成启动配置 `AMD_GPU_GET_CACHE_TTL`:`cmd/exporter/main.go` 解析一次并在取值非法时立即退出,exporter 与 gpuagent 的 options 像 `exit-on-agent-down` 一样把它传下去,最终由 `cacheRead` 应用。未设置时保持上游 15 s 缓存,因此不设该变量时补丁不改变任何行为;`0s` 让每次 scrape 都发起新的 GPUGet。缓存周围的加锁、查询超时和错误处理保持不变。测试覆盖解析器、15 s / 1 s / 0 s 三种缓存判定、错误路径、`0s` 下 16 个并发读取,以及 exporter 与 agent 的默认值。只有 `0s` 能保证每次 scrape 都是新读数:缓存时间戳在 GPUGet 返回后才记录,任何正的 TTL 都会让部分 scrape 拿到缓存数据。每次读取在 RPC 期间持有缓存锁,一小时的 MI355X 运行在最差 1.01 s 间隔下未受影响。它取代此前复制自 [functionstackx/device-metrics-exporter#1](https://github.com/functionstackx/device-metrics-exporter/pull/1) 的版本;旧版本读取该变量两次,并把默认值改成了 1 s。
88

99
`base-runtime.json` 从保留的官方 OCI 归档提取原始 Docker 配置,以及 61 个关键路径的文件哈希和符号链接目标。恢复过程先验证 GPUAgent、入口脚本、AMD-SMI、ROCm sysdeps 和配套二进制,再使用原始环境变量、入口、标签及工作目录导入根文件系统。Enroot 已合并镜像层、规范化所有权和权限,并生成 `/etc` 启动文件,因此重建基础镜像使用新标识,不能称为原始 OCI 镜像。之后仅在新增镜像层替换 `/home/amd/bin/server`。`AMD_GPU_GET_CACHE_TTL=0s` 强制每次 exporter 请求发起新的 GPUGet RPC。这消除了 exporter 响应复用;硬件实际刷新率、采集开销和基准测试中的一秒采集仍需实机验证。
1010

0 commit comments

Comments
 (0)