Phase ML1: Pool v1 memset 89.73% overhead 軽量化 (+15.34% improvement)
## Summary - ChatGPT により bench_profile.h の setenv segfault を修正(RTLD_NEXT 経由に切り替え) - core/box/pool_zero_mode_box.h 新設:ENV キャッシュ経由で ZERO_MODE を統一管理 - core/hakmem_pool.c で zero mode に応じた memset 制御(FULL/header/off) - A/B テスト結果:ZERO_MODE=header で +15.34% improvement(1M iterations, C6-heavy) ## Files Modified - core/box/pool_api.inc.h: pool_zero_mode_box.h include - core/bench_profile.h: glibc setenv → malloc+putenv(segfault 回避) - core/hakmem_pool.c: zero mode 参照・制御ロジック - core/box/pool_zero_mode_box.h (新設): enum/getter - CURRENT_TASK.md: Phase ML1 結果記載 ## Test Results | Iterations | ZERO_MODE=full | ZERO_MODE=header | Improvement | |-----------|----------------|-----------------|------------| | 10K | 3.06 M ops/s | 3.17 M ops/s | +3.65% | | 1M | 23.71 M ops/s | 27.34 M ops/s | **+15.34%** | 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -64,9 +64,7 @@
|
||||
// HAKMEM_LEARN=1 HAKMEM_DYN1_AUTO=1 HAKMEM_CAP_MID_DYN1=64 ./app
|
||||
//
|
||||
// # W_MAX学習(Canary方式で安全に探索)
|
||||
// HAKMEM_LEARN=1 HAKMEM_WMAX_LEARN=1 \
|
||||
// HAKMEM_WMAX_CANDIDATES_MID=1.4,1.6,1.8 \
|
||||
// HAKMEM_WMAX_CANDIDATES_LARGE=1.3,1.6,2.0 ./app
|
||||
// HAKMEM_LEARN=1 HAKMEM_WMAX_LEARN=1 HAKMEM_WMAX_CANDIDATES_MID=1.4,1.6,1.8 HAKMEM_WMAX_CANDIDATES_LARGE=1.3,1.6,2.0 ./app
|
||||
//
|
||||
// 注意事項:
|
||||
// - 学習モードは高負荷ワークロードで効果的
|
||||
@ -356,8 +354,8 @@ static void* learner_main(void* arg) {
|
||||
if (sum > budget_mid) {
|
||||
while (sum > budget_mid) {
|
||||
// find min need with cap>min_mid
|
||||
int best_k = -1; double best_need = 1e9; int best_cap=0;
|
||||
for (int k=0;k<m;k++){ int slot=idx_map[k]; int cap=GET_MID_CAP(np, slot); if (cap<=min_mid) continue; if (need[k] < best_need){ best_need=need[k]; best_k=k; best_cap=cap; } }
|
||||
int best_k = -1; double best_need = 1e9;
|
||||
for (int k=0;k<m;k++){ int slot=idx_map[k]; int cap=GET_MID_CAP(np, slot); if (cap<=min_mid) continue; if (need[k] < best_need){ best_need=need[k]; best_k=k; } }
|
||||
if (best_k < 0) break;
|
||||
int slot = idx_map[best_k]; int nv = GET_MID_CAP(np, slot) - step_mid; if (nv < min_mid) nv = min_mid; SET_MID_CAP(np, slot, nv); sum = 0; for (int k=0;k<m;k++){ int sl=idx_map[k]; sum += GET_MID_CAP(np, sl); }
|
||||
}
|
||||
@ -379,12 +377,14 @@ static void* learner_main(void* arg) {
|
||||
while (sum > budget_lg) {
|
||||
int best=-1; double best_need=1e9;
|
||||
for (int i=0;i<L25_NUM_CLASSES;i++){ if (np->large_cap[i] <= min_lg) continue; if (need_lg[i] < best_need){ best_need=need_lg[i]; best=i; } }
|
||||
if (best<0) break; int nv=np->large_cap[best]-step_lg; if (nv<min_lg) nv=min_lg; np->large_cap[best]=nv; sum=0; for (int i=0;i<L25_NUM_CLASSES;i++) sum += np->large_cap[i];
|
||||
if (best<0) break;
|
||||
int nv=np->large_cap[best]-step_lg; if (nv<min_lg) nv=min_lg; np->large_cap[best]=nv; sum=0; for (int i=0;i<L25_NUM_CLASSES;i++) sum += np->large_cap[i];
|
||||
}
|
||||
} else if (wf_enabled && sum < budget_lg) {
|
||||
while (sum < budget_lg) {
|
||||
int best=-1; double best_need=-1e9; for (int i=0;i<L25_NUM_CLASSES;i++){ if (need_lg[i] > best_need){ best_need=need_lg[i]; best=i; } }
|
||||
if (best<0) break; np->large_cap[best]+=step_lg; sum += step_lg;
|
||||
if (best<0) break;
|
||||
np->large_cap[best]+=step_lg; sum += step_lg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user