Phase MID-V35-HOTPATH-OPT-1 complete: +7.3% on C6-heavy

Step 0: Geometry SSOT
  - New: core/box/smallobject_mid_v35_geom_box.h (L1/L2 consistency)
  - Fix: C6 slots/page 102→128 in L2 (smallobject_cold_iface_mid_v3.c)
  - Applied: smallobject_mid_v35.c, smallobject_segment_mid_v3.c

Step 1-3: ENV gates for hotpath optimizations
  - New: core/box/mid_v35_hotpath_env_box.h
    * HAKMEM_MID_V35_HEADER_PREFILL (default 0)
    * HAKMEM_MID_V35_HOT_COUNTS (default 1)
    * HAKMEM_MID_V35_C6_FASTPATH (default 0)
  - Implementation: smallobject_mid_v35.c
    * Header prefill at refill boundary (Step 1)
    * Gated alloc_count++ in hot path (Step 2)
    * C6 specialized fast path with constant slot_size (Step 3)

A/B Results:
  C6-heavy (257–768B): 8.75M→9.39M ops/s (+7.3%, 5-run mean) 
  Mixed (16–1024B): 9.98M→9.96M ops/s (-0.2%, within noise) ✓

Decision: FROZEN - defaults OFF, C6-heavy推奨ON, Mixed現状維持
Documentation: ENV_PROFILE_PRESETS.md updated

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-12 19:19:25 +09:00
parent e95e61f0ff
commit fe70e3baf5
9 changed files with 211 additions and 57 deletions

View File

@ -5,6 +5,9 @@
#include <stdio.h>
#include "box/smallobject_cold_iface_mid_v3_box.h"
#include "box/smallobject_stats_mid_v3_box.h"
#include "box/smallobject_mid_v35_geom_box.h" // Phase MID-V35-HOTPATH-OPT-1: geometry SSOT
#include "box/mid_v35_hotpath_env_box.h" // Phase MID-V35-HOTPATH-OPT-1: Step 1-3 ENV gates
#include "tiny_region_id.h" // For tiny_region_id_write_header
// SmallPageMeta is defined in smallobject_segment_mid_v3_box.h
#include "box/smallobject_segment_mid_v3_box.h"
@ -19,15 +22,9 @@ static __thread SmallSegment_MID_v3 *tls_mid_segment = NULL;
// ============================================================================
// Helper: class_idx to slots
// ============================================================================
static uint32_t class_idx_to_slots(uint32_t class_idx) {
switch (class_idx) {
case 5: return 170; // C5: 257-384B
case 6: return 102; // C6: 385-640B
case 7: return 64; // C7: 641-1024B
default: return 0;
}
}
// Phase MID-V35-HOTPATH-OPT-1: Use geom_box as Single Source of Truth
// See: core/box/smallobject_mid_v35_geom_box.h
// (Removed local class_idx_to_slots() which had wrong C6 value: 102 instead of 128)
// ============================================================================
// Cold Interface Implementation
@ -63,10 +60,21 @@ SmallPageMeta_MID_v3* small_cold_mid_v3_refill_page(uint32_t class_idx) {
// Initialize page for allocation
page->class_idx = class_idx;
page->capacity = class_idx_to_slots(class_idx);
page->capacity = mid_v35_slots_per_page(class_idx);
page->alloc_count = 0;
page->free_count = 0;
// Phase MID-V35-HOTPATH-OPT-1 Step 1: Header prefill at refill boundary
// When enabled, write all headers now so hot path can skip per-alloc header writes
if (mid_v35_header_prefill_enabled()) {
size_t slot_size = mid_v35_slot_size(class_idx);
uint32_t cap = page->capacity;
uint8_t *p = (uint8_t*)page_ptr;
for (uint32_t i = 0; i < cap; i++) {
tiny_region_id_write_header(p + i * slot_size, class_idx);
}
}
return page;
}