Files
hakmem/core/box/smallobject_hotbox_v3_box.h
Moe Charm (CI) acc64f2438 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>
2025-12-10 09:08:18 +09:00

80 lines
2.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// smallobject_hotbox_v3_box.h - SmallObject HotHeap v3 (C7-first skeleton)
//
// Phase A/B: 型と TLS / stats を用意し、front が呼べる枠を置く。
// まだ中身は v1 fallbackso_alloc は NULL を返す)。
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <stdatomic.h>
#include "tiny_geometry_box.h"
#include "smallobject_hotbox_v3_env_box.h"
#include "tiny_region_id.h"
#ifndef SMALLOBJECT_NUM_CLASSES
#define SMALLOBJECT_NUM_CLASSES TINY_NUM_CLASSES
#endif
struct tiny_heap_page_t;
struct TinySlabMeta;
struct SuperSlab;
typedef struct so_page_v3 {
void* freelist;
uint32_t used;
uint32_t capacity;
uint32_t block_size;
uint32_t class_idx;
uint32_t flags;
void* base; // carve 後のユーザ領域先頭
void* slab_base; // 64KiB slab 基底page_of 用ヘッダを書き込む)
struct TinySlabMeta* meta;
struct SuperSlab* ss;
uint16_t slab_idx;
struct tiny_heap_page_t* lease_page;
void* slab_ref; // kept as a generic token; currently same as lease_page for v1
struct so_page_v3* next;
} so_page_v3;
typedef struct so_class_v3 {
so_page_v3* current;
so_page_v3* partial;
uint16_t max_partial_pages;
uint16_t partial_count;
uint32_t block_size;
} so_class_v3;
typedef struct so_ctx_v3 {
so_class_v3 cls[SMALLOBJECT_NUM_CLASSES];
} so_ctx_v3;
typedef struct so_stats_class_v3 {
_Atomic uint64_t route_hits;
_Atomic uint64_t alloc_calls;
_Atomic uint64_t alloc_refill;
_Atomic uint64_t alloc_fallback_v1;
_Atomic uint64_t free_calls;
_Atomic uint64_t free_fallback_v1;
_Atomic uint64_t page_of_fail;
} so_stats_class_v3;
// Stats helpers (defined in core/smallobject_hotbox_v3.c)
int so_v3_stats_enabled(void);
void so_v3_record_route_hit(uint8_t ci);
void so_v3_record_alloc_call(uint8_t ci);
void so_v3_record_alloc_refill(uint8_t ci);
void so_v3_record_alloc_fallback(uint8_t ci);
void so_v3_record_free_call(uint8_t ci);
void so_v3_record_free_fallback(uint8_t ci);
void so_v3_record_page_of_fail(uint8_t ci);
// TLS accessor (core/smallobject_hotbox_v3.c)
so_ctx_v3* so_tls_get(void);
// Hot path API (Phase B: stub → always fallback to v1)
void* so_alloc(uint32_t class_idx);
void so_free(uint32_t class_idx, void* ptr);
// C7-only pointer membership check (read-only, no state change)
int smallobject_hotbox_v3_can_own_c7(void* ptr);