Commit Graph

2 Commits

Author SHA1 Message Date
0dba67ba9d Phase v11a-2: Core MID v3.5 implementation - segment, cold iface, stats, learner
Implement 5-layer infrastructure for multi-class MID v3.5 (C5-C7, 257-1KiB):

1. SegmentBox_mid_v3 (L2 Physical)
   - core/smallobject_segment_mid_v3.c (9.5 KB)
   - 2MiB segments, 64KiB pages (32 per segment)
   - Per-class free page stacks (LIFO)
   - RegionIdBox registration
   - Slots: C5→170, C6→102, C7→64

2. ColdIface_mid_v3 (L2→L1)
   - core/box/smallobject_cold_iface_mid_v3_box.h (NEW)
   - core/smallobject_cold_iface_mid_v3.c (3.5 KB)
   - refill: get page from free stack or new segment
   - retire: calculate free_hit_ratio, publish stats, return to stack
   - Clean separation: TLS cache for hot path, ColdIface for cold path

3. StatsBox_mid_v3 (L2→L3)
   - core/smallobject_stats_mid_v3.c (7.2 KB)
   - Circular buffer history (1000 events)
   - Per-page metrics: class_idx, allocs, frees, free_hit_ratio_bps
   - Periodic aggregation (every 100 retires)
   - Learner notification callback

4. Learner v2 (L3)
   - core/smallobject_learner_v2.c (11 KB)
   - Multi-class aggregation: allocs[8], retire_count[8], avg_free_hit_bps[8]
   - Exponential smoothing (90% history + 10% new)
   - Per-class efficiency tracking
   - Stats snapshot API
   - Route decision disabled for v11a-2 (v11b feature)

5. Build Integration
   - Modified Makefile: added 4 new .o files (segment, cold_iface, stats, learner)
   - Updated box header prototypes
   - Clean compilation, all dependencies resolved

Architecture Decision Implementation:
- v7 remains frozen (C5/C6 research preset)
- MID v3.5 becomes unified 257-1KiB main path
- Multi-class isolation: per-class free stacks
- Dormant infrastructure: linked but not active (zero overhead)

Performance:
- Build: clean compilation
- Sanity benchmark: 27.3M ops/s (no regression vs v10)
- Memory: ~30MB RSS (baseline maintained)

Design Compliance:
 Layer separation: L2 (segment) → L2 (cold iface) → L3 (stats) → L3 (learner)
 Hot path clean: alloc/free never touch stats/learner
 Backward compatible: existing MID v3 routes unchanged
 Transparent: v11a-2 is dormant (no behavior change)

Next Phase (v11a-3):
- Activate C5/C6/C7 routing through MID v3.5
- Connect TLS cache to segment refill
- Verify performance under load
- Then Phase v11a-4: dynamic C5 ratio routing

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-12 06:37:06 +09:00
babd884b96 Phase v11a-1: Infrastructure - Multi-class segment and learner v2 box definitions
Create core box definitions for MID v3.5 consolidation (Phase v11a):

1. smallobject_segment_mid_v3_box.h
   - Multi-class unified segment (2MiB, C5-C7)
   - Per-class free page stacks
   - SmallHeapCtx_MID_v3 for TLS caching
   - Refill/retire/validation APIs

2. smallobject_stats_mid_v3_box.h
   - SmallPageStatsMID_v3: per-page lifetime stats
   - Aggregation for Learner input
   - Free hit ratio tracking (basis points)

3. smallobject_learner_v2_box.h
   - SmallLearnerStatsV2: multi-class and global metrics
   - Extended from v7 (C5-only ratio) to full workload analysis
   - Per-class retire efficiency, global free hit ratio
   - Decision API for route optimization

4. smallobject_policy_v2_box.h
   - SmallPolicyV2: routing with Learner integration
   - Version-based TLS cache invalidation
   - Route update from Learner stats
   - Backward compatible with v1 interface

Dependency graph:
  segment → stats → learner → policy → malloc routing

Architecture Decision: Option A (MID v3.5 consolidation)
- v7 frozen as C5/C6-only research preset
- MID v3.5 becomes 257-1KiB main implementation
- Learner scope: multi-class tracking (C5 ratio primary, Phase v11a)
- Future (v11b): multi-dimensional optimization

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-12 06:20:01 +09:00