Add Artemis stress test for detecting cache aliasing bugs. Include statistical hypothesis evaluations, fix validation data, and run reports for validation across architectures.

Signed-off-by: Robert Allan James <robert.allan.james@gmail.com>
This commit is contained in:
Robert Allan James
2026-08-02 14:49:52 -04:00
parent 148c4aa12c
commit 1cb68502fb
44 changed files with 5610173 additions and 2680 deletions
+153
View File
@@ -249,6 +249,159 @@ Block 4133
ART-INIT
ART-BOOT-ENTRY
WELCOME
Block 4160
( Surface stress test storage. Manual-invoke only -- )
( never called from the entry sequence above. )
2000 CONSTANT ART-STRESS-CAP
CREATE ART-STRESS-LBN ART-STRESS-CAP CELLS ALLOT
CREATE ART-STRESS-PAT ART-STRESS-CAP CELLS ALLOT
VARIABLE ART-STRESS-N
VARIABLE ART-STRESS-PASS
VARIABLE ART-STRESS-FAIL
VARIABLE S-I
VARIABLE S-IDX
VARIABLE S-STRIDE
VARIABLE S-CUR
VARIABLE S-ACTUAL
Block 4161
( Trial record accessors )
: SLBN@ ( i -- lbn ) CELLS ART-STRESS-LBN + @ ;
: SLBN! ( lbn i -- ) CELLS ART-STRESS-LBN + ! ;
: SPAT@ ( i -- pat ) CELLS ART-STRESS-PAT + @ ;
: SPAT! ( pat i -- ) CELLS ART-STRESS-PAT + ! ;
Block 4172
( CSV emission part 1 -- one row per trial, tagged )
( so it can be grepped like the DoE CSVs. Every )
( trial emits a row, pass or fail -- no silent skips. )
: SCSV-HEADER ( n -- )
." [ARTSTRESS] HEADER,n=" DUP . CR
." [ARTSTRESS] trial,lbn,pat,result" CR ;
: SCSV-ROW ( -- )
." [ARTSTRESS] "
S-I @ . ." ,"
S-I @ SLBN@ . ." ,"
S-I @ SPAT@ . ." ,"
S-ACTUAL @ S-I @ SPAT@ = IF 1 ELSE 0 THEN . CR ;
Block 4173
( CSV emission part 2 -- SUMMARY marker. A run that )
( got killed/timed out mid-way never prints this -- )
( its absence means the data is incomplete, full )
( stop, not "probably fine." )
: SCSV-SUMMARY ( -- )
." [ARTSTRESS] SUMMARY,"
ART-STRESS-N @ . ." ,"
ART-STRESS-PASS @ . ." ,"
ART-STRESS-FAIL @ . CR ;
Block 4162
( Coprime-stride walk over the data index space -- )
( visits every index at most once before repeating, )
( so no O(n) scan against past picks is needed. )
( ART-DATA-BLKS = 22998 = 2 * 3 * 3833. )
: S-COPRIME? ( n -- flag )
DUP 3 MOD 0= IF DROP 0 EXIT THEN
3833 MOD 0<> ;
: S-INIT-WALK ( -- )
0 ART-DATA-BLKS 1 - RANDOM S-CUR !
BEGIN
1 ART-DATA-BLKS 1 - RANDOM 1 OR
DUP S-COPRIME?
UNTIL
S-STRIDE ! ;
Block 4171
( Step the walk; skip anything already allocated by )
( someone else -- never clobbers pre-existing data. )
: SPICK ( -- idx )
BEGIN
S-CUR @ S-STRIDE @ + ART-DATA-BLKS MOD S-CUR !
S-CUR @ FM-TEST 0=
UNTIL
S-CUR @ ;
Block 4163
( Write one trial: alloc a fresh random free block, )
( tag it with a trial-derived pattern, and persist )
( it through the real BLK-ALLOC-style path. )
: SWRITE1 ( -- )
SPICK S-IDX !
S-IDX @ FM-SET
Q.1 S-IDX @ BLK-HEAT!
S-IDX @ ART-DATA-LBN + S-I @ SLBN!
S-I @ 255 AND S-I @ SPAT!
S-I @ SLBN@ BLK-FETCH
1024 S-I @ SPAT@ FILL
S-I @ SLBN@ BLK-PERSIST ;
Block 4164
( Verify one trial: by now the 8-slot devblock cache )
( has likely evicted and reloaded this block many )
( times over -- a real round trip, not a cache hit. )
: SVERIFY1 ( -- )
S-I @ SLBN@ BLK-FETCH C@ S-ACTUAL !
S-ACTUAL @ S-I @ SPAT@ = IF
1 ART-STRESS-PASS +!
ELSE
1 ART-STRESS-FAIL +!
." STRESS MISMATCH trial=" S-I @ .
." lbn=" S-I @ SLBN@ . CR
THEN
SCSV-ROW ;
Block 4166
( Clamp reps into range, kept in its own block so )
( SVERIFY1 above has room for CSV emission. )
: ART-STRESS-CLAMP ( reps -- reps' )
DUP ART-STRESS-CAP > IF DROP ART-STRESS-CAP THEN
DUP 1 < IF DROP 1 THEN ;
Block 4165
( Driver part 1: banner, then the write+verify loops. )
( Split across several blocks -- a colon definition )
( must fit in a single 1024-byte/16-line block here. )
( This is a data-collection fixture, not a fast/live )
( check -- same posture as the DoE campaign. K is not )
( gated on live, it's recorded for offline analysis. )
: ART-STRESS-BANNER ( n -- )
DUP SCSV-HEADER
." Artemis: surface stress test, " . ." trials" CR
ART-K-TOTAL Q.PRINT ." K before" CR ;
: ART-STRESS-RUN ( -- )
ART-STRESS-N @ 0 DO I S-I ! SWRITE1 LOOP
ART-STRESS-N @ 0 DO I S-I ! SVERIFY1 LOOP ;
Block 4167
( Driver part 2: pass/fail summary line )
: ART-STRESS-REPORT ( -- )
." Artemis stress: "
ART-STRESS-PASS @ . ." passed, "
ART-STRESS-FAIL @ . ." failed" CR ;
Block 4168
( Driver part 3: free everything this run touched, )
( print K after for the record. Only write/verify )
( mismatches gate PASS/FAIL -- a background heartbeat )
( decay tick during a long run is expected and is not )
( itself a failure. )
: ART-STRESS-CLEANUP ( -- )
ART-STRESS-N @ 0 DO
I S-I ! S-I @ SLBN@ BLK-FREE
LOOP
ART-K-TOTAL Q.PRINT ." K after (should match)" CR
SCSV-SUMMARY
ART-STRESS-FAIL @ 0 = IF
." PASS: surface stress test" CR
ELSE
." FAIL: surface stress test" CR
THEN ;
Block 4169
( Top-level entry points )
: ART-STRESS-TEST ( seed reps -- )
ART-STRESS-CLAMP ART-STRESS-N ! SEED
0 ART-STRESS-PASS ! 0 ART-STRESS-FAIL !
S-INIT-WALK
ART-STRESS-N @ ART-STRESS-BANNER
ART-STRESS-RUN ART-STRESS-REPORT
ART-STRESS-CLEANUP ;
: ART-STRESS ( -- ) 424242 50 ART-STRESS-TEST ;
Block 4170
( Disabled by default -- uncomment to run the surface )
( stress test automatically at every boot. Normally )
( invoked manually instead: ART-STRESS or )
( <seed> <reps> ART-STRESS-TEST from the console. )
\ ART-STRESS
Block 4851
( Cheap touch target for Phase 3 fleet DoE workload -- O(1), )
( unlike ART-TICK/ART-STATUS which scan all ART-DATA-BLKS. )