stadium_admit()'s mass==1 refusal looked like a hard blocker for 1024-byte blocks, but stadium_word_dispatch()'s real candidate construction proves Stadium cells carry pure identity/heat/bookkeeping, never the resident's actual content -- a block patron follows the same shape (identity=LBN, payload unused), so this was real, scoped work, not a case for stubbing. New stadium_blocks.h/.c mirror stadium_words.c's admission/cooling shape, keyed by (quota_slot, lbn) in a fixed-capacity open-addressing hash table (tombstone deletion) instead of a dense array, since LBN space isn't densely bounded like word_id. Wired into block_word_block()/buffer()/ update() (block_words.c), __STARKERNEL__-guarded. stadium_dispatch()'s MIGRATE case now calls blk_flush(lbn) for real instead of printing "(stub)". Three new Kconfig constants (STADIUM_BLOCK_HEAT_QUANTUM/ STADIUM_BLOCK_COOL_RATE_Q48/STADIUM_BLOCK_TRACK_CAP_MULT) mirror the word-patron ones, same three-layer wiring. VM-COOL/DELIVER/EXPIRE stay explicit punch-list items -- VM-COOL deferred pending the still-iterating Tripod/Zuse/messaging vision, DELIVER/EXPIRE are their own future subsystem integrations per FABRIC.md's own "open, not resolved" notes. Verified clean compile (zero warnings) and clean boot to REPL with conservation intact (resident_sum + reservoir == Q48_ONE) on all three architectures (amd64/aarch64/riscv64); BLOCK/BUFFER touches exercised live from the REPL with no crash; a 22,000-distinct-block flood loop against an artificially shrunk Stadium ran clean under heavy admission load. A live MIGRATE console fire was not directly observed this session (root-caused to a pre-existing reservoir-floor/density-eviction interaction unrelated to this change, documented in FABRIC-3.md) -- flagged as an honest follow-up, not silently claimed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CXjAPTEKrgY2Mrk25KoLDn
256 lines
9.1 KiB
C
256 lines
9.1 KiB
C
/*
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
|
||
*/
|
||
|
||
/*
|
||
* StarForth VM Feature Configuration
|
||
*
|
||
* This header is the single source of truth for VM build-time defaults.
|
||
* Build systems may override any option via -D<FLAG>=<value>, but every
|
||
* translation unit sees these defaults even if no -D is provided.
|
||
*
|
||
* Hosted + kernel builds both force-include this header (see Makefiles),
|
||
* so new toggles belong here with a documented owner.
|
||
*/
|
||
|
||
#ifndef STARFORTH_CONFIG_H
|
||
#define STARFORTH_CONFIG_H
|
||
|
||
/* Base defaults (match 2025-12-26 hosted baseline) */
|
||
#define STARFORTH_CONFIG_STRICT_PTR_DEFAULT 1
|
||
#define STARFORTH_CONFIG_ENABLE_HOTWORDS_CACHE_DEFAULT 0
|
||
#define STARFORTH_CONFIG_ENABLE_PIPELINING_DEFAULT 0
|
||
#define STARFORTH_CONFIG_ROLLING_WINDOW_SIZE_DEFAULT 4096
|
||
#define STARFORTH_CONFIG_TRANSITION_WINDOW_SIZE_DEFAULT 8
|
||
#define STARFORTH_CONFIG_ADAPTIVE_SHRINK_RATE_DEFAULT 50
|
||
#define STARFORTH_CONFIG_ADAPTIVE_MIN_WINDOW_SIZE_DEFAULT 256
|
||
#define STARFORTH_CONFIG_ADAPTIVE_CHECK_FREQUENCY_DEFAULT 512
|
||
#define STARFORTH_CONFIG_ADAPTIVE_GROWTH_THRESHOLD_DEFAULT 5
|
||
#define STARFORTH_CONFIG_INITIAL_DECAY_SLOPE_Q48_DEFAULT 21845
|
||
#define STARFORTH_CONFIG_DECAY_MIN_INTERVAL_DEFAULT 1000ULL
|
||
#define STARFORTH_CONFIG_DECAY_RATE_PER_US_Q16_DEFAULT 1
|
||
#define STARFORTH_CONFIG_HEARTBEAT_THREAD_ENABLED_DEFAULT 1
|
||
#define STARFORTH_CONFIG_HEARTBEAT_TICK_NS_DEFAULT 10000ULL
|
||
#define STARFORTH_CONFIG_HEARTBEAT_INFERENCE_FREQUENCY_DEFAULT 1000
|
||
#define STARFORTH_CONFIG_STADIUM_VM_MEMORY_PERCENT_DEFAULT 50
|
||
#define STARFORTH_CONFIG_STADIUM_CONTAINS_DEPTH_MAX_DEFAULT 5
|
||
#define STARFORTH_CONFIG_STADIUM_CAPACITY_TICK_DEFAULT 4000
|
||
#define STARFORTH_CONFIG_STADIUM_MEMORY_PERCENT_DEFAULT 1
|
||
#define STARFORTH_CONFIG_STADIUM_WORD_HEAT_QUANTUM_DEFAULT 2048
|
||
#define STARFORTH_CONFIG_STADIUM_WORD_COOL_RATE_Q48_DEFAULT 21845
|
||
#define STARFORTH_CONFIG_STADIUM_BLOCK_HEAT_QUANTUM_DEFAULT 2048
|
||
#define STARFORTH_CONFIG_STADIUM_BLOCK_COOL_RATE_Q48_DEFAULT 21845
|
||
#define STARFORTH_CONFIG_STADIUM_BLOCK_TRACK_CAP_MULT_DEFAULT 2
|
||
#define STARFORTH_CONFIG_HEARTBEAT_CHECK_FREQUENCY_DEFAULT 256
|
||
#define STARFORTH_CONFIG_HEARTBEAT_WINDOW_TUNING_FREQUENCY_DEFAULT 1000
|
||
#define STARFORTH_CONFIG_HEARTBEAT_SLOPE_VALIDATION_FREQUENCY_DEFAULT 5000
|
||
#define STARFORTH_CONFIG_SSM_ENTROPY_HIGH_THRESHOLD_DEFAULT 0.75
|
||
#define STARFORTH_CONFIG_SSM_CV_HIGH_THRESHOLD_DEFAULT 0.15
|
||
#define STARFORTH_CONFIG_SSM_TEMPORAL_DECAY_THRESHOLD_DEFAULT 0.5
|
||
#define STARFORTH_CONFIG_SSM_TEMPORAL_DECAY_LOW_THRESHOLD_DEFAULT 0.3
|
||
#define STARFORTH_CONFIG_SSM_HYSTERESIS_TICKS_DEFAULT 5
|
||
#define STARFORTH_CONFIG_SPECULATION_THRESHOLD_Q48_DEFAULT (0x8000LL)
|
||
#define STARFORTH_CONFIG_SPECULATION_DEPTH_DEFAULT 1
|
||
#define STARFORTH_CONFIG_MIN_SAMPLES_FOR_SPECULATION_DEFAULT 10
|
||
#define STARFORTH_CONFIG_MISPREDICTION_COST_Q48_DEFAULT (25LL << 16)
|
||
/* 1.10 in Q48.16 (1.10 * 65536 = 72089.6, rounds to 0x1199A). Was shipped
|
||
* for years as 0x11999AL (an extra hex digit, ~17.6 in Q48.16, an order of
|
||
* magnitude off from the documented 1.10 intent) -- found while migrating
|
||
* this constant to Kconfig (see rev x in
|
||
* docs/working/architecture/VM-FLEET-ATTRACTOR-DESIGN-20260705.md) and
|
||
* fixed on Bob's explicit instruction (rev y). */
|
||
#define STARFORTH_CONFIG_MINIMUM_PREFETCH_ROI_DEFAULT (0x1199AL)
|
||
|
||
/* Public macros (overridable via -D) */
|
||
#ifndef STRICT_PTR
|
||
#define STRICT_PTR STARFORTH_CONFIG_STRICT_PTR_DEFAULT
|
||
#endif
|
||
|
||
#ifndef VM_STRICT_PTR
|
||
#define VM_STRICT_PTR STRICT_PTR
|
||
#endif
|
||
|
||
#ifndef ENABLE_HOTWORDS_CACHE
|
||
#define ENABLE_HOTWORDS_CACHE STARFORTH_CONFIG_ENABLE_HOTWORDS_CACHE_DEFAULT
|
||
#endif
|
||
|
||
#ifndef ENABLE_PIPELINING
|
||
#define ENABLE_PIPELINING STARFORTH_CONFIG_ENABLE_PIPELINING_DEFAULT
|
||
#endif
|
||
|
||
#ifndef ROLLING_WINDOW_SIZE
|
||
#define ROLLING_WINDOW_SIZE STARFORTH_CONFIG_ROLLING_WINDOW_SIZE_DEFAULT
|
||
#endif
|
||
|
||
#ifndef TRANSITION_WINDOW_SIZE
|
||
#define TRANSITION_WINDOW_SIZE STARFORTH_CONFIG_TRANSITION_WINDOW_SIZE_DEFAULT
|
||
#endif
|
||
|
||
#ifndef ADAPTIVE_SHRINK_RATE
|
||
#define ADAPTIVE_SHRINK_RATE STARFORTH_CONFIG_ADAPTIVE_SHRINK_RATE_DEFAULT
|
||
#endif
|
||
|
||
#ifndef ADAPTIVE_MIN_WINDOW_SIZE
|
||
#define ADAPTIVE_MIN_WINDOW_SIZE STARFORTH_CONFIG_ADAPTIVE_MIN_WINDOW_SIZE_DEFAULT
|
||
#endif
|
||
|
||
#ifndef ADAPTIVE_CHECK_FREQUENCY
|
||
#define ADAPTIVE_CHECK_FREQUENCY STARFORTH_CONFIG_ADAPTIVE_CHECK_FREQUENCY_DEFAULT
|
||
#endif
|
||
|
||
#ifndef ADAPTIVE_GROWTH_THRESHOLD
|
||
#define ADAPTIVE_GROWTH_THRESHOLD STARFORTH_CONFIG_ADAPTIVE_GROWTH_THRESHOLD_DEFAULT
|
||
#endif
|
||
|
||
#ifndef INITIAL_DECAY_SLOPE_Q48
|
||
#define INITIAL_DECAY_SLOPE_Q48 STARFORTH_CONFIG_INITIAL_DECAY_SLOPE_Q48_DEFAULT
|
||
#endif
|
||
|
||
#ifndef DECAY_MIN_INTERVAL
|
||
#define DECAY_MIN_INTERVAL STARFORTH_CONFIG_DECAY_MIN_INTERVAL_DEFAULT
|
||
#endif
|
||
|
||
#ifndef DECAY_RATE_PER_US_Q16
|
||
#define DECAY_RATE_PER_US_Q16 STARFORTH_CONFIG_DECAY_RATE_PER_US_Q16_DEFAULT
|
||
#endif
|
||
|
||
#ifndef HEARTBEAT_THREAD_ENABLED
|
||
#define HEARTBEAT_THREAD_ENABLED STARFORTH_CONFIG_HEARTBEAT_THREAD_ENABLED_DEFAULT
|
||
#endif
|
||
|
||
#ifndef HEARTBEAT_TICK_NS
|
||
#define HEARTBEAT_TICK_NS STARFORTH_CONFIG_HEARTBEAT_TICK_NS_DEFAULT
|
||
#endif
|
||
|
||
#ifndef HEARTBEAT_INFERENCE_FREQUENCY
|
||
#define HEARTBEAT_INFERENCE_FREQUENCY STARFORTH_CONFIG_HEARTBEAT_INFERENCE_FREQUENCY_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_VM_MEMORY_PERCENT
|
||
#define STADIUM_VM_MEMORY_PERCENT STARFORTH_CONFIG_STADIUM_VM_MEMORY_PERCENT_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_CONTAINS_DEPTH_MAX
|
||
#define STADIUM_CONTAINS_DEPTH_MAX STARFORTH_CONFIG_STADIUM_CONTAINS_DEPTH_MAX_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_CAPACITY_TICK
|
||
#define STADIUM_CAPACITY_TICK STARFORTH_CONFIG_STADIUM_CAPACITY_TICK_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_MEMORY_PERCENT
|
||
#define STADIUM_MEMORY_PERCENT STARFORTH_CONFIG_STADIUM_MEMORY_PERCENT_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_WORD_HEAT_QUANTUM
|
||
#define STADIUM_WORD_HEAT_QUANTUM STARFORTH_CONFIG_STADIUM_WORD_HEAT_QUANTUM_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_WORD_COOL_RATE_Q48
|
||
#define STADIUM_WORD_COOL_RATE_Q48 STARFORTH_CONFIG_STADIUM_WORD_COOL_RATE_Q48_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_BLOCK_HEAT_QUANTUM
|
||
#define STADIUM_BLOCK_HEAT_QUANTUM STARFORTH_CONFIG_STADIUM_BLOCK_HEAT_QUANTUM_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_BLOCK_COOL_RATE_Q48
|
||
#define STADIUM_BLOCK_COOL_RATE_Q48 STARFORTH_CONFIG_STADIUM_BLOCK_COOL_RATE_Q48_DEFAULT
|
||
#endif
|
||
|
||
#ifndef STADIUM_BLOCK_TRACK_CAP_MULT
|
||
#define STADIUM_BLOCK_TRACK_CAP_MULT STARFORTH_CONFIG_STADIUM_BLOCK_TRACK_CAP_MULT_DEFAULT
|
||
#endif
|
||
|
||
#ifndef HEARTBEAT_CHECK_FREQUENCY
|
||
#define HEARTBEAT_CHECK_FREQUENCY STARFORTH_CONFIG_HEARTBEAT_CHECK_FREQUENCY_DEFAULT
|
||
#endif
|
||
|
||
#ifndef HEARTBEAT_WINDOW_TUNING_FREQUENCY
|
||
#define HEARTBEAT_WINDOW_TUNING_FREQUENCY STARFORTH_CONFIG_HEARTBEAT_WINDOW_TUNING_FREQUENCY_DEFAULT
|
||
#endif
|
||
|
||
#ifndef HEARTBEAT_SLOPE_VALIDATION_FREQUENCY
|
||
#define HEARTBEAT_SLOPE_VALIDATION_FREQUENCY STARFORTH_CONFIG_HEARTBEAT_SLOPE_VALIDATION_FREQUENCY_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SSM_ENTROPY_HIGH_THRESHOLD
|
||
#define SSM_ENTROPY_HIGH_THRESHOLD STARFORTH_CONFIG_SSM_ENTROPY_HIGH_THRESHOLD_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SSM_CV_HIGH_THRESHOLD
|
||
#define SSM_CV_HIGH_THRESHOLD STARFORTH_CONFIG_SSM_CV_HIGH_THRESHOLD_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SSM_TEMPORAL_DECAY_THRESHOLD
|
||
#define SSM_TEMPORAL_DECAY_THRESHOLD STARFORTH_CONFIG_SSM_TEMPORAL_DECAY_THRESHOLD_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SSM_TEMPORAL_DECAY_LOW_THRESHOLD
|
||
#define SSM_TEMPORAL_DECAY_LOW_THRESHOLD STARFORTH_CONFIG_SSM_TEMPORAL_DECAY_LOW_THRESHOLD_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SSM_HYSTERESIS_TICKS
|
||
#define SSM_HYSTERESIS_TICKS STARFORTH_CONFIG_SSM_HYSTERESIS_TICKS_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SPECULATION_THRESHOLD_Q48
|
||
#define SPECULATION_THRESHOLD_Q48 STARFORTH_CONFIG_SPECULATION_THRESHOLD_Q48_DEFAULT
|
||
#endif
|
||
|
||
#ifndef SPECULATION_DEPTH
|
||
#define SPECULATION_DEPTH STARFORTH_CONFIG_SPECULATION_DEPTH_DEFAULT
|
||
#endif
|
||
|
||
#ifndef MIN_SAMPLES_FOR_SPECULATION
|
||
#define MIN_SAMPLES_FOR_SPECULATION STARFORTH_CONFIG_MIN_SAMPLES_FOR_SPECULATION_DEFAULT
|
||
#endif
|
||
|
||
#ifndef MISPREDICTION_COST_Q48
|
||
#define MISPREDICTION_COST_Q48 STARFORTH_CONFIG_MISPREDICTION_COST_Q48_DEFAULT
|
||
#endif
|
||
|
||
#ifndef MINIMUM_PREFETCH_ROI
|
||
#define MINIMUM_PREFETCH_ROI STARFORTH_CONFIG_MINIMUM_PREFETCH_ROI_DEFAULT
|
||
#endif
|
||
|
||
#endif /* STARFORTH_CONFIG_H */
|