Files
hakmem/core/hakmem_smallmid.h

47 lines
1.4 KiB
C
Raw Normal View History

/**
* hakmem_smallmid.h - Small-Mid Allocator Stub (archived implementation)
*
* SmallMid /使
* Tiny/Tiny-Plus 1KB
*
* hak_alloc_api / hakmem_tiny
* API Stub Box
*
* archive/smallmid/
*/
#ifndef HAKMEM_SMALLMID_H
#define HAKMEM_SMALLMID_H
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
// 旧実装と互換の定数だけ残す(値は使われないがビルドを安定させる)
Phase 17-1 Revision: Small-Mid Front Box Only (ChatGPT Strategy) STRATEGY CHANGE (ChatGPT reviewed): - Phase 17-1: Build FRONT BOX ONLY (no dedicated SuperSlab backend) - Backend: Reuse existing Tiny SuperSlab/SharedPool APIs - Goal: Measure performance impact before building dedicated infrastructure - A/B test: Does thin front layer improve 256-1KB performance? RATIONALE (ChatGPT analysis): 1. Tiny/Middle/Large need different properties - same SuperSlab causes conflict 2. Metadata shapes collide - struct bloat → L1 miss increase 3. Learning signals get muddied - size-specific control becomes difficult IMPLEMENTATION: - Reduced size classes: 5 → 3 (256B/512B/1KB only) - Removed dedicated SuperSlab backend stub - Backend: Direct delegation to hak_tiny_alloc/free - TLS freelist: Thin front cache (32/24/16 capacity) - Fast path: TLS hit (pop/push with header 0xb0) - Slow path: Backend alloc via Tiny (no TLS refill) - Free path: TLS push if space, else delegate to Tiny ARCHITECTURE: Tiny: 0-255B (C0-C5, unchanged) Small-Mid: 256-1KB (SM0-SM2, Front Box, backend=Tiny) Mid: 8KB-32KB (existing) FILES CHANGED: - hakmem_smallmid.h: Reduced to 3 classes, updated docs - hakmem_smallmid.c: Removed SuperSlab stub, added backend delegation NEXT STEPS: - Integrate into hak_alloc_api.inc.h routing - A/B benchmark: Small-Mid ON/OFF comparison - If successful (2x improvement), consider Phase 17-2 dedicated backend 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 01:51:43 +09:00
#define SMALLMID_NUM_CLASSES 3
// 便宜上の範囲定義小さくしておくが、smallmid_is_enabled()==false なので実行はされない)
#define SMALLMID_MIN_SIZE (256)
#define SMALLMID_MAX_SIZE (1024)
// API スタブ
// 旧実装と互換のヘルパー(インライン宣言のみ、実体は stub .c で定義)
bool smallmid_is_in_range(size_t size);
void smallmid_init(void);
void* smallmid_alloc(size_t size);
void smallmid_free(void* ptr);
void smallmid_thread_exit(void);
// SmallMid が有効かどうか(現在は常に false を返す stub 実装)
bool smallmid_is_enabled(void);
#ifdef __cplusplus
}
#endif
#endif // HAKMEM_SMALLMID_H