Skip to content

Commit 5d3c26e

Browse files
refactor: reorganize estimation and server scripts [code:qws] [system:MiyabiG]
1 parent 502dfb3 commit 5d3c26e

18 files changed

Lines changed: 46 additions & 42 deletions

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ trigger_benchpark_pipeline:
207207
generate_estimate_matrix:
208208
stage: generate
209209
script:
210-
- bash scripts/generate_estimate_from_uuid.sh
210+
- bash scripts/estimation/generate_reestimate_pipeline.sh
211211
tags:
212212
- general
213213
artifacts:

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ benchkit/
7777
│ ├── job_functions.sh # 共通関数定義(CSVパース、System_CSV検索)
7878
│ ├── bk_functions.sh # FOM/SECTION/OVERLAP出力標準化関数
7979
│ ├── result.sh # 結果JSON変換(SECTION/OVERLAP対応、pipeline_timing付加)
80-
│ ├── send_results.sh # 結果転送(uuid/timestamp書き戻し)
80+
│ ├── result_server/
8181
│ ├── record_timestamp.sh # Unixエポックタイムスタンプ記録
8282
│ ├── collect_timing.sh # パイプラインタイミング収集(build/queue/run時間)
83-
│ ├── estimate_common.sh # 性能推定共通ライブラリ
84-
│ ├── run_estimate.sh # 推定実行ラッパー
85-
│ ├── send_estimate.sh # 推定結果転送
86-
│ ├── fetch_result_by_uuid.sh # UUID指定結果取得
87-
│ ├── generate_estimate_from_uuid.sh # UUID指定推定パイプライン生成
83+
│ │ ├── api.sh # result_server JSON取得共通
84+
│ │ ├── send_results.sh # 結果転送(uuid/timestamp書き戻し)
85+
│ │ ├── send_estimate.sh # 推定結果転送
86+
│ │ └── fetch_result_by_uuid.sh # UUID指定結果取得
87+
│ ├── estimation/
88+
│ │ ├── common.sh # 性能推定共通ライブラリ
89+
│ │ ├── run.sh # 推定実行ラッパー
90+
│ │ ├── test_reestimate.sh # 再推定確認ヘルパー
91+
│ │ └── generate_reestimate_pipeline.sh # UUID指定推定パイプライン生成
8892
│ ├── wait_for_nfs.sh # NFS同期待機(現在コメントアウト中)
8993
│ └── test_submit.sh # テスト実行用
9094
├── .gitlab-ci.yml # メインCI定義
@@ -225,7 +229,7 @@ python -m pytest tests/ -v
225229
- `run.sh``scripts/bk_functions.sh``source` し、`bk_emit_result` / `bk_emit_section` / `bk_emit_overlap` で標準化された結果出力を行う
226230
- `record_timestamp.sh` は run/build_run ジョブ(計算ノード上)でビルド・実行の開始/終了時刻を記録する
227231
- `collect_timing.sh``result.sh` は send_results ジョブ(Docker ランナー `fncx-curl-jq` 上)で実行される。`collect_timing.sh``pipeline_timing`(build/queue/run時間)を集計し、`result.sh` で結果をJSON形式に変換(`pipeline_timing` 情報を自動付加)する
228-
- `scripts/send_results.sh` で結果サーバに転送・性能推定トリガー
232+
- `scripts/result_server/send_results.sh` で結果サーバに転送・性能推定トリガー
229233

230234
### 3. 結果転送・保存
231235
- `results/result[0-9].json` を結果サーバに転送
@@ -238,7 +242,7 @@ python -m pytest tests/ -v
238242

239243
- 推定対象システム: `ESTIMATE_SYSTEMS`(job_functions.sh で定義、例: MiyabiG, RC_GH200)
240244
- `estimate.sh` がアプリ固有の推定ロジックを実装(`programs/<code>/estimate.sh`
241-
- `estimate_common.sh` が共通関数(API呼び出し、JSON出力等)を提供
245+
- `scripts/estimation/common.sh` が共通関数(API呼び出し、JSON出力等)を提供
242246
- 簡易推定と詳細推定の双方を将来的に受け入れられる設計を前提とする
243247
- UUID指定による再推定もサポート
244248
- `estimate_result_uuid` を指定すると、その estimate から `source_result_uuid` を引いて再推定
@@ -250,7 +254,7 @@ python -m pytest tests/ -v
250254
- `benchpark-bridge/scripts/ci_generator.sh` により `.gitlab-ci.benchpark.yml` を自動生成
251255
- `benchpark-bridge/scripts/runner.sh` でBenchPark(Spack/Ramble)を実行
252256
- `benchpark-bridge/scripts/result_converter.py` でRamble結果をBenchKit JSON形式に変換
253-
- 結果は `scripts/send_results.sh` で結果サーバに転送
257+
- 結果は `scripts/result_server/send_results.sh` で結果サーバに転送
254258

255259
---
256260

benchpark-bridge/scripts/ci_generator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ${job_prefix}_send:
6363
- test -n \"\$RESULT_SERVER\" && echo \"RESULT_SERVER is set\" || echo \"RESULT_SERVER is NOT set\"
6464
- test -n \"\$RESULT_SERVER_KEY\" && echo \"RESULT_SERVER_KEY is set\" || echo \"RESULT_SERVER_KEY is NOT set\"
6565
- echo \"Sending results to server\"
66-
- bash scripts/send_results.sh
66+
- bash scripts/result_server/send_results.sh
6767
6868
" >> "$output"
6969
}
@@ -156,4 +156,4 @@ ${job_prefix}_run:
156156

157157
done < "$BENCHPARK_LIST"
158158

159-
echo "BenchPark GitLab CI configuration generated: $OUTPUT_FILE"
159+
echo "BenchPark GitLab CI configuration generated: $OUTPUT_FILE"

docs/cx/BENCHKIT_GAP_ANALYSIS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ However, estimation is still not yet broadly deployed across multiple applicatio
6464
| ベンチマーク実行定義 | アプリごとの build/run/list を保持し、継続実行可能であること | `programs/*``build.sh` `run.sh` `list.csv`、一部 `estimate.sh` がある | 追加や修正がまだ人手中心。雛形生成や申請導線がない | 申請・承認・AI 連携の前提になる ||
6565
| CI ジョブ生成 | system と queue 情報を使って CI 実行を生成すること | `matrix_generate.sh``job_functions.sh` が実装済み | 拠点接続の検証や onboarding 手順が未整理 | 拠点追加、予算管理、申請フォームの自動化に影響 ||
6666
| 結果正規化 | `run.sh` 出力を Result JSON に正規化すること | `bk_emit_result``bk_emit_section``bk_emit_overlap``result.sh` が実装済み | app ごとの差異を自動検証する仕組みが弱い | 推定、可視化、AI 診断の入力品質に直結 ||
67-
| 性能推定 | Result JSON から Estimate JSON を生成し、可視化可能であること | `estimate_common.sh``run_estimate.sh``send_estimate.sh``estimated` 画面あり。`qws` では軽量推定と詳細ダミー推定、section ごとの package 指定、補助データ参照、section-level fallback、requested/applied package 識別、top-level applicability end state、推定元 result と推定結果自体の UUID / timestamp 保持まで動作する | 横展開はまだ `qws` 中心。複数 detailed package の本実装、再推定比較運用、他 app への適用が未完成 | AI 駆動、将来機評価、継続的フィードバックの基盤になる | 最優先 |
67+
| 性能推定 | Result JSON から Estimate JSON を生成し、可視化可能であること | `scripts/estimation/common.sh``scripts/estimation/run.sh``scripts/result_server/send_estimate.sh``estimated` 画面あり。`qws` では軽量推定と詳細ダミー推定、section ごとの package 指定、補助データ参照、section-level fallback、requested/applied package 識別、top-level applicability end state、推定元 result と推定結果自体の UUID / timestamp 保持まで動作する | 横展開はまだ `qws` 中心。複数 detailed package の本実装、再推定比較運用、他 app への適用が未完成 | AI 駆動、将来機評価、継続的フィードバックの基盤になる | 最優先 |
6868
| 推定結果表示 | Estimate JSON を一覧・詳細で表示できること | `result_server/routes/estimated.py` とテンプレートが実装済み。requested/applied package、applicability、estimate UUID の基本表示も入っている | section / overlap 単位の package applicability や `not_applicable` 詳細の見せ方、比較 UI がまだ弱い | 推定運用を本格化すると重要度が上がる ||
6969
| 使用量集計 | 実行使用量を集計し、運用判断に使えること | `node_hours.py``/results/usage` が実装済み | 予算主体、アカウント主体、runner 主体との結び付きがない | 多拠点運用と予算管理の核になる ||
7070
| ソース出自情報 | 最上位アプリケーションの commit hash を追跡すること | `bk_fetch_source``source_info` が実装済み | すべての app で徹底されていない。 archive/file の場合は commit hash を持てない | 推定比較、AI 最適化、回帰分析の再現性に直結 ||
@@ -183,7 +183,7 @@ Once the estimation specification is clarified, many other design decisions beco
183183

184184
| 項目 | 仕様上の期待 | 現状実装 | GAP | 優先度 |
185185
|---|---|---|---|---|
186-
| 共通推定エントリ | app 側 `estimate.sh` を薄くし、共通呼び出し順を持つこと | `estimate_common.sh` と package 呼び出し型の `qws/estimate.sh` がある | 他 app への横展開が未着手 | 最優先 |
186+
| 共通推定エントリ | app 側 `estimate.sh` を薄くし、共通呼び出し順を持つこと | `scripts/estimation/common.sh` と package 呼び出し型の `qws/estimate.sh` がある | 他 app への横展開が未着手 | 最優先 |
187187
| 軽量推定 package | FOM-only、weak scaling 前提、補正なしなら FOM 一定 | `lightweight_fom_scaling` が実装済み | 参照実装は 1 本のみ。current/future 側で別 model を使う実運用は未整備 ||
188188
| 適用可能性判定 | 不足入力を `applicable/fallback/not_applicable/needs_remeasurement` で扱うこと | `lightweight_fom_scaling``instrumented_app_sections_dummy` はこれらを扱え、final Estimate JSON では `applicable``partially_applicable``fallback``not_applicable` を表現できる。requested/applied package の識別も保持できる | 複数 detailed package 間の分岐、より細かい fallback 選択、UI 表示は未実装 ||
189189
| package metadata | package 名、版、required inputs、fallback policy を持つこと | 軽量/詳細ダミーとも最小 metadata を持つ | richer metadata を discovery や UI に活かす実装がまだ無い ||
@@ -198,7 +198,7 @@ Once the estimation specification is clarified, many other design decisions beco
198198

199199
この表から、現在の最小核は以下と整理できる。
200200

201-
1. `estimate_common.sh` を中心とした共通呼び出しと Estimate JSON 出力
201+
1. `scripts/estimation/common.sh` を中心とした共通呼び出しと Estimate JSON 出力
202202
2. `lightweight_fom_scaling` による FOM-only 軽量推定
203203
3. `instrumented_app_sections_dummy` による区間時間ベース詳細ダミー推定
204204
4. 推定元 result UUID / timestamp の引き回し

docs/cx/ESTIMATION_PACKAGE_SHELL_API_SPEC.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ This document is a lower-level specification under [`ESTIMATION_PACKAGE_SPEC.md`
2828

2929
## 2. 目的 / Purpose
3030

31-
本 API の目的は、推定パッケージごとの差を吸収しつつ、`estimate_common.sh` や app 側 `estimate.sh` から一貫した呼び出しができるようにすることである。
31+
本 API の目的は、推定パッケージごとの差を吸収しつつ、`scripts/estimation/common.sh` や app 側 `estimate.sh` から一貫した呼び出しができるようにすることである。
3232

33-
The purpose of this API is to allow consistent invocation from `estimate_common.sh` and application-side `estimate.sh` while absorbing differences among estimation packages.
33+
The purpose of this API is to allow consistent invocation from `scripts/estimation/common.sh` and application-side `estimate.sh` while absorbing differences among estimation packages.
3434

3535
## 3. 基本方針 / Basic Policy
3636

@@ -182,7 +182,7 @@ In the future, application-side `estimate.sh` should preferably be limited to:
182182

183183
```sh
184184
BK_ESTIMATION_PACKAGE=lightweight_fom_scaling
185-
source scripts/estimate_common.sh
185+
source scripts/estimation/common.sh
186186
source scripts/estimation/packages/${BK_ESTIMATION_PACKAGE}.sh
187187

188188
read_values "$1"

docs/cx/ESTIMATION_PACKAGE_SPEC.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ In this form, the application side is responsible only for package selection and
539539
- package を shell で書くか外部ツールで書くか
540540
- package metadata の完全な構造
541541

542-
これらは、現行の `estimate_common.sh` と app 側 `estimate.sh` の実装経験を踏まえて段階的に固定する。
542+
これらは、現行の `scripts/estimation/common.sh` と app 側 `estimate.sh` の実装経験を踏まえて段階的に固定する。
543543

544544
This document does not yet fix:
545545

@@ -549,7 +549,7 @@ This document does not yet fix:
549549
- whether packages are written in shell or external tools
550550
- the complete schema of package metadata
551551

552-
These should be fixed incrementally based on implementation experience with the current `estimate_common.sh` and application-side `estimate.sh`.
552+
These should be fixed incrementally based on implementation experience with the current `scripts/estimation/common.sh` and application-side `estimate.sh`.
553553

554554
## 9. 次に必要な下位仕様 / Next Detailed Specifications
555555

docs/cx/REESTIMATION_SPEC.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ Optionally, the following may also be supplied:
148148

149149
現行実装では、以下の要素が存在する。
150150

151-
- `run_estimate.sh` が app ごとの `estimate.sh` を呼び出す
152-
- `send_estimate.sh` が推定結果を結果サーバに送信する
151+
- `scripts/estimation/run.sh` が app ごとの `estimate.sh` を呼び出す
152+
- `scripts/result_server/send_estimate.sh` が推定結果を結果サーバに送信する
153153
- Estimate JSON には推定元 benchmark result の UUID を `estimate_metadata.source_result_uuid` として保持できる
154154
- Estimate JSON には保存対象としての推定結果自体の UUID / timestamp を `estimate_metadata.estimation_result_uuid` / `estimation_result_timestamp` として保持できる
155155
- `requested_estimation_package` と実際に適用された `estimation_package` を区別できる
156156
- `applicability` を通じて `applicable``partially_applicable``fallback``not_applicable` を最終状態として保持できる
157157

158158
In the current implementation, the following already exist:
159159

160-
- `run_estimate.sh` to invoke app-specific `estimate.sh`
161-
- `send_estimate.sh` to send estimation results to the result server
160+
- `scripts/estimation/run.sh` to invoke app-specific `estimate.sh`
161+
- `scripts/result_server/send_estimate.sh` to send estimation results to the result server
162162
- the ability to retain the source benchmark-result UUID as `estimate_metadata.source_result_uuid`
163163
- the ability to retain the estimate-result UUID / timestamp as `estimate_metadata.estimation_result_uuid` / `estimation_result_timestamp`
164164
- a distinction between `requested_estimation_package` and the actually applied `estimation_package`

docs/guides/add-estimation-to-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
set -euo pipefail
4646

4747
BK_ESTIMATION_PACKAGE="lightweight_fom_scaling"
48-
source scripts/estimate_common.sh
48+
source scripts/estimation/common.sh
4949
source "scripts/estimation/packages/${BK_ESTIMATION_PACKAGE}.sh"
5050

5151
bk_run_estimation "$1"
@@ -150,7 +150,7 @@ bk_emit_overlap \
150150
set -euo pipefail
151151

152152
BK_ESTIMATION_PACKAGE="instrumented_app_sections_dummy"
153-
source scripts/estimate_common.sh
153+
source scripts/estimation/common.sh
154154
source "scripts/estimation/packages/${BK_ESTIMATION_PACKAGE}.sh"
155155

156156
bk_run_estimation "$1"

programs/qws/estimate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# estimate.sh — Reference package-based estimation entrypoint for qws
33

4-
source scripts/estimate_common.sh
4+
source scripts/estimation/common.sh
55

66
BK_ESTIMATION_PACKAGE="${BK_ESTIMATION_PACKAGE:-instrumented_app_sections_dummy}"
77
BK_ESTIMATION_BASELINE_SYSTEM="Fugaku"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
2-
# estimate_common.sh — Common function library for performance estimation
2+
# common.sh — Common function library for performance estimation
33
#
44
# Provides shared variables and functions used by application-specific
55
# estimate scripts (programs/<code>/estimate.sh).
66
#
77
# Usage:
8-
# source scripts/estimate_common.sh
8+
# source scripts/estimation/common.sh
99

1010
set -euo pipefail
1111

12-
source "$(dirname "${BASH_SOURCE[0]}")/result_server_client.sh"
12+
source "$(dirname "${BASH_SOURCE[0]}")/../result_server/api.sh"
1313

1414
# ---------------------------------------------------------------------------
1515
# Global variables — populated by read_values

0 commit comments

Comments
 (0)