perf(v4): POST at a boot's pace -- v3's per-suite put-back, and a lookup that rejects by two bytes (#189)
Ruled (Captain Bob, 2026-11-14): "Find the TCG cost first". v3's whole POST took the amd64
accept from about 3 m 15 s to 8 m 45 s, and aarch64 past its 570 s (logs/20261114-091651,
STOPPED, committed). Profiled on the host (gprof, mesh-boot): 87% of the time in POST's
lines, about 280,000 opcodes a line -- the interpreter's dictionary lookup.
- POST puts the dictionary back before each of v3's suites, as v3's run_test_suite does
("to remove test-created words"): a mark, (POST), forgotten and made again
(V4_POST_SUITE). Only the dictionary: SCR, BASE and the rest stay as the cases left them.
- (LOOKUP) tries each entry by its count and first character first -- one fetch of the
name's first cell, masked -- and only then its hidden flag and the whole name. The answer
is the same; an entry that cannot be it costs a few opcodes, not some forty.
mesh-boot: 37.7 s -> 15.7 s, POST 990 of 990. make -C v4 test: all v4 tests passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -161,6 +161,8 @@ set HDR-NFA here ", (TELL-FORGOTTEN) #id, #, 0 #, HDR-NFA #, HDR-LINK set
|
||||
\ (D)+0 where the name starts (D)+1 the name being looked up
|
||||
\ (D)+2 the name being copied, or the entry being looked at
|
||||
\ (D)+3 a count (D)+4 whether a lookup has gone on to FORTH
|
||||
\ (D)+5 the name looked up's count and first character, as an entry's first
|
||||
\ two bytes: each entry is tried by them first (#189 Phase 7: POST's time)
|
||||
|
||||
\ ( -- bytes ) what an entry for a name of (D)+3 characters takes: its name
|
||||
\ cells and four more
|
||||
@@ -231,11 +233,14 @@ set HDR-NFA here ", (TELL-FORGOTTEN) #id, #, 0 #, HDR-NFA #, HDR-LINK set
|
||||
HNONE: drop jump H
|
||||
HDONE: drop
|
||||
0 (D)+4 a! ! \ not yet on to FORTH
|
||||
(D)+1 a! @ dup 1 + C@ 2* 2* 2* 2* 2* 2* 2* 2* SWAP C@ + (D)+5 a! !
|
||||
CONTEXT a! @ a! @
|
||||
L: if END
|
||||
(D)+2 a! !
|
||||
dup (D)+2 a! !
|
||||
-2 + a! @ a! @ 65535 and (D)+5 a! @ xor if PRE drop jump OLDER
|
||||
PRE: drop \ its count and first character are the string's: is it visible,
|
||||
(D)+2 a! @ -3 + a! @ 2 and if VISIBLE drop jump OLDER
|
||||
VISIBLE: drop
|
||||
VISIBLE: drop \ and is it all the same?
|
||||
(D)+2 a! @ -2 + a! @ 4* (D) a! ! \ its name
|
||||
(D)+1 a! @ C@ 1 + (D)+3 a! ! \ the count byte and the characters
|
||||
C: (D)+3 a! @ if SAME -1 + dup ! \ k
|
||||
|
||||
Reference in New Issue
Block a user