Results: - A/B test: +1.89% on Mixed (10-run, clean env) - Baseline: 51.96M ops/s - Optimized: 52.94M ops/s - Improvement: +984K ops/s (+1.89%) - C6-heavy verification: +7.86% (nonlegacy_mask works correctly, no misfires) Strategy: - Extend Phase 9 (C0-C3 DUALHOT) to C4-C7 LEGACY DIRECT - Fail-Fast principle: Never misclassify MID/ULTRA/V7 as LEGACY - nonlegacy_mask: Cached at init, hot path uses single bit operation Success factors: 1. Performance improvement: +1.89% (1.9x GO threshold) 2. Safety verified: nonlegacy_mask prevents MID v3 misfire in C6-heavy 3. Phase 9 coexistence: C0-C3 (Phase 9) + C4-C7 (Phase 10) = full LEGACY coverage 4. Minimal overhead: Single bit operation in hot path (mask & (1u<<class)) Implementation: - Patch 1: ENV gate box (free_tiny_fast_mono_legacy_direct_env_box.h) - ENV: HAKMEM_FREE_TINY_FAST_MONO_LEGACY_DIRECT=0/1 (default 0) - nonlegacy_mask cached (reuses free_policy_fast_v2_nonlegacy_mask()) - Probe window: 64 (avoid bench_profile putenv race) - Patch 2: Early-exit in free_tiny_fast() (malloc_tiny_fast.h) - Conditions: !nonlegacy_mask, route==LEGACY, !LARSON_FIX, done==1 - Direct call: tiny_legacy_fallback_free_base() - Patch 3: Visibility (free_path_stats_box.h) - mono_legacy_direct_hit counter (compile-out in release) - Patch 4: cleanenv extension (run_mixed_10_cleanenv.sh) - ENV leak protection Safety verification (C6-heavy): - OFF: 19.75M ops/s - ON: 21.30M ops/s (+7.86%) - nonlegacy_mask correctly excludes C6 (MID v3 active) - Improvement from C0-C5, C7 direct path acceleration Files modified: - core/bench_profile.h: add to MIXED_TINYV3_C7_SAFE preset - core/front/malloc_tiny_fast.h: early-exit insertion - core/box/free_path_stats_box.h: counter - core/box/free_tiny_fast_mono_legacy_direct_env_box.h: NEW (ENV gate + nonlegacy_mask) - scripts/run_mixed_10_cleanenv.sh: ENV leak protection Health check: PASSED (all profiles) Promotion: Added to MIXED_TINYV3_C7_SAFE preset (default ON, opt-out) Rollback: HAKMEM_FREE_TINY_FAST_MONO_LEGACY_DIRECT=0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
24 lines
930 B
Bash
Executable File
24 lines
930 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# 10-run Mixed benchmark with explicit clean ENV for frozen/research knobs.
|
|
# Purpose: avoid "bench_setenv_default() does not override exported ENV" drift.
|
|
|
|
profile=${HAKMEM_PROFILE:-MIXED_TINYV3_C7_SAFE}
|
|
iters=${ITERS:-20000000}
|
|
ws=${WS:-400}
|
|
runs=${RUNS:-10}
|
|
|
|
# Force known research knobs OFF to avoid accidental carry-over.
|
|
export HAKMEM_TINY_HEADER_WRITE_ONCE=${HAKMEM_TINY_HEADER_WRITE_ONCE:-0}
|
|
export HAKMEM_MALLOC_TINY_DIRECT=${HAKMEM_MALLOC_TINY_DIRECT:-0}
|
|
export HAKMEM_ENV_SNAPSHOT_SHAPE=${HAKMEM_ENV_SNAPSHOT_SHAPE:-0}
|
|
export HAKMEM_FREE_TINY_FAST_MONO_DUALHOT=${HAKMEM_FREE_TINY_FAST_MONO_DUALHOT:-0}
|
|
export HAKMEM_FREE_TINY_FAST_MONO_LEGACY_DIRECT=${HAKMEM_FREE_TINY_FAST_MONO_LEGACY_DIRECT:-0}
|
|
|
|
for i in $(seq 1 "${runs}"); do
|
|
echo "=== Run ${i}/${runs} ==="
|
|
HAKMEM_PROFILE="${profile}" ./bench_random_mixed_hakmem "${iters}" "${ws}" 1 2>&1 | rg "Throughput" || true
|
|
done
|
|
|