ENV Cleanup: Delete Ultra HEAP & BG Remote dead code (-1,096 LOC)

Deleted files (11):
- core/ultra/ directory (6 files: tiny_ultra_heap.*, tiny_ultra_page_arena.*)
- core/front/tiny_ultrafront.h
- core/tiny_ultra_fast.inc.h
- core/hakmem_tiny_ultra_front.inc.h
- core/hakmem_tiny_ultra_simple.inc
- core/hakmem_tiny_ultra_batch_box.inc

Edited files (10):
- core/hakmem_tiny.c: Remove Ultra HEAP #includes, move ultra_batch_for_class()
- core/hakmem_tiny_tls_state_box.inc: Delete TinyUltraFront, g_ultra_simple
- core/hakmem_tiny_phase6_wrappers_box.inc: Delete ULTRA_SIMPLE block
- core/hakmem_tiny_alloc.inc: Delete Ultra-Front code block
- core/hakmem_tiny_init.inc: Delete ULTRA_SIMPLE ENV loading
- core/hakmem_tiny_remote_target.{c,h}: Delete g_bg_remote_enable/batch
- core/tiny_refill.h: Remove BG Remote check (always break)
- core/hakmem_tiny_background.inc: Delete BG Remote drain loop

Deleted ENV variables:
- HAKMEM_TINY_ULTRA_HEAP (build flag, undefined)
- HAKMEM_TINY_ULTRA_L0
- HAKMEM_TINY_ULTRA_HEAP_DUMP
- HAKMEM_TINY_ULTRA_PAGE_DUMP
- HAKMEM_TINY_ULTRA_FRONT
- HAKMEM_TINY_BG_REMOTE (no getenv, dead code)
- HAKMEM_TINY_BG_REMOTE_BATCH (no getenv, dead code)
- HAKMEM_TINY_ULTRA_SIMPLE (references only)

Impact:
- Code reduction: -1,096 lines
- Binary size: 305KB → 304KB (-1KB)
- Build: PASS
- Sanity: 15.69M ops/s (3 runs avg)
- Larson: 1 crash observed (seed 43, likely existing instability)

Notes:
- Ultra HEAP never compiled (#if HAKMEM_TINY_ULTRA_HEAP undefined)
- BG Remote variables never initialized (g_bg_remote_enable always 0)
- Ultra SLIM (ultra_slim_alloc_box.h) preserved (active 4-layer path)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-11-27 04:35:47 +09:00
parent f4978b1529
commit 6b791b97d4
22 changed files with 61 additions and 1096 deletions

View File

@ -1,123 +0,0 @@
// tiny_ultrafront.h - Phase UltraFront: 密結合 Tiny Front Path (実験箱)
//
// 目的:
// - 既存の FrontGate + Unified Cache を前提に、
// malloc/free の Tiny 経路を「1本のインラインパス」に近づける実験的フロント。
// - Box Theory 的には Front 層の別バリアント Box として扱い、
// ENV で A/B 切り替え可能にする。
//
// 特徴:
// - Tiny 範囲 (size <= tiny_get_max_size()) 専用。
// - Unified Cache を直接叩く (unified_cache_pop_or_refill / unified_cache_push)。
// - Header 書き込み/読取りは tiny_region_id_* を利用して安全性を維持。
//
// ENV:
// HAKMEM_TINY_ULTRA_FRONT=1 ... UltraFront 有効 (デフォルト: 0, 無効)
//
// 統合ポイント:
// - malloc ラッパ (hak_wrappers.inc.h) の FrontGate ブロック内から
// tiny_ultrafront_malloc(size) を first try として呼び出す。
// - free ラッパから tiny_ultrafront_free(ptr) を first try として呼び出す。
#ifndef HAK_FRONT_TINY_ULTRA_FRONT_H
#define HAK_FRONT_TINY_ULTRA_FRONT_H
#include <stddef.h>
#include <stdint.h>
#include "../hakmem_build_flags.h"
#include "../hakmem_tiny.h" // tiny_get_max_size, hak_tiny_size_to_class
// #include "tiny_unified_cache.h" // Removed (A/B test: OFF is faster)
#include "../tiny_region_id.h" // tiny_region_id_write_header / read_header
// ============================================================================
// ENV Control (cached, lazy init)
// ============================================================================
static inline int tiny_ultrafront_enabled(void) {
static int g_enable = -1;
if (__builtin_expect(g_enable == -1, 0)) {
const char* e = getenv("HAKMEM_TINY_ULTRA_FRONT");
g_enable = (e && *e && *e != '0') ? 1 : 0;
#if !HAKMEM_BUILD_RELEASE
if (g_enable) {
fprintf(stderr, "[UltraFront-INIT] tiny_ultrafront_enabled() = %d\n", g_enable);
fflush(stderr);
}
#endif
}
return g_enable;
}
// ============================================================================
// UltraFront malloc/free (Tiny 専用)
// ============================================================================
// UltraFront Tiny allocation
// - size: ユーザー要求サイズ
// - 戻り値: USER ポインタ or NULL (Unified miss時は通常経路にフォールバックさせる)
static inline void* tiny_ultrafront_malloc(size_t size) {
// Tiny 範囲外は扱わない
if (__builtin_expect(size == 0 || size > tiny_get_max_size(), 0)) {
return NULL;
}
// サイズ→クラス (branchless LUT)
int class_idx = hak_tiny_size_to_class(size);
if (__builtin_expect(class_idx < 0 || class_idx >= TINY_NUM_CLASSES, 0)) {
return NULL;
}
// Unified Cache から BASE を取得 (hit or refill)
// DELETED (A/B test: OFF is faster)
// void* base = unified_cache_pop_or_refill(class_idx);
// if (__builtin_expect(base == NULL, 0)) {
// // Unified Cache disabled or refill failed → 通常経路にフォールバック
// return NULL;
// }
// Unified Cache removed → 通常経路にフォールバック
return NULL;
}
// UltraFront Tiny free
// - ptr: USER ポインタ
// - 戻り値: 1=UltraFront で処理済み, 0=フォールバック (通常 free 経路へ)
static inline int tiny_ultrafront_free(void* ptr) {
if (__builtin_expect(!ptr, 0)) {
return 0;
}
#if HAKMEM_TINY_HEADER_CLASSIDX
// ページ境界ガード: ptr がページ先頭 (offset==0) の場合、ptr-1 は
// 別ページ/未マップ領域となり得るので UltraFront では扱わない。
uintptr_t off = (uintptr_t)ptr & 0xFFFu;
if (__builtin_expect(off == 0, 0)) {
return 0;
}
// Header ベースの class_idx 読取り (tiny_region_id_read_header は magic/範囲チェック込み)
int class_idx = tiny_region_id_read_header(ptr);
if (__builtin_expect(class_idx < 0 || class_idx >= TINY_NUM_CLASSES, 0)) {
// Tiny ヘッダが無い or 壊れている → 非Tiny / 別ドメインなのでフォールバック
return 0;
}
// void* base = (void*)((uint8_t*)ptr - 1);
// Unified Cache へ BASE を push
// DELETED (A/B test: OFF is faster)
// int pushed = unified_cache_push(class_idx, base);
// if (__builtin_expect(pushed, 1)) {
// return 1;
// }
// Unified Cache removed → 通常 free 経路へ
return 0;
#else
// ヘッダモードでなければ UltraFront は何もしない
(void)ptr;
return 0;
#endif
}
#endif // HAK_FRONT_TINY_ULTRA_FRONT_H