perf(v4): the lookup keeps its key in B; POST sends one line per suite, not three (#189)

Captain Bob's "Find the TCG cost first", continued. aarch64 still ran out of its 570 s at 281972ab
(logs/20261114-133155, STOPPED); amd64 passed in 253 s (logs/20261114-132732).

- (LOOKUP): the count-and-first-character key in register B while the entries are walked, and the
  xt kept on the stack until an entry passes it -- about 19 opcodes for an entry that cannot be the
  word, from 28. The answer is the same.
- POST: a suite begins with one line, DECIMAL FORTH DEFINITIONS FORGET (POST); its mark is made by
  the state line of its first case run (a skipped kernel case passes it on).

mesh-boot: 15.7 s -> 12.2 s (37.7 s before this work), POST 990 of 990. make -C v4 test: all passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-17 13:11:47 +00:00
parent 281972abb2
commit 5b752693ae
5 changed files with 28 additions and 8 deletions
+4 -3
View File
@@ -234,11 +234,12 @@ set HDR-NFA here ", (TELL-FORGOTTEN) #id, #, 0 #, HDR-NFA #, HDR-LINK set
HDONE: drop HDONE: drop
0 (D)+4 a! ! \ not yet on to FORTH 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! ! (D)+1 a! @ dup 1 + C@ 2* 2* 2* 2* 2* 2* 2* 2* SWAP C@ + (D)+5 a! !
(D)+5 b! \ B stays on it while the entries are walked
CONTEXT a! @ a! @ CONTEXT a! @ a! @
L: if END L: if END
dup (D)+2 a! ! dup -2 + a! @ a! @ 65535 and @b xor if PRE
-2 + a! @ a! @ 65535 and (D)+5 a! @ xor if PRE drop jump OLDER drop -1 + a! @ jump L \ not it: the entry before
PRE: drop \ its count and first character are the string's: is it visible, PRE: drop (D)+2 a! ! \ its count and first character are the string's: is it visible,
(D)+2 a! @ -3 + a! @ 2 and if VISIBLE drop jump OLDER (D)+2 a! @ -3 + a! @ 2 and if VISIBLE drop jump OLDER
VISIBLE: drop \ and is it all the same? VISIBLE: drop \ and is it all the same?
(D)+2 a! @ -2 + a! @ 4* (D) a! ! \ its name (D)+2 a! @ -2 + a! @ 4* (D) a! ! \ its name
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
# STOPPED -- timed out (development boot, not the protocol)
`timeout 570 scripts/nightly.sh accept aarch64` on 281972ab (#189 Phase 7: v3's whole POST, 990 cases, after the
per-suite put-back and the lookup's two-byte test; amd64 on that commit 253 s). The 570 s ran out in POST: the log
ends in the capsules' parity lines. aarch64 took 460-473 s with the 539-case POST (logs/20261113-170343,
logs/20261113-191606). Followed by a faster lookup and fewer POST lines.
+12 -5
View File
@@ -13,11 +13,14 @@
#define SHOWN_STACK 32u /* and how many of the values it left */ #define SHOWN_STACK 32u /* and how many of the values it left */
static const char state_line[] = "DECIMAL FORTH DEFINITIONS"; static const char state_line[] = "DECIMAL FORTH DEFINITIONS";
static const char state_mark[] = "DECIMAL FORTH DEFINITIONS CREATE (POST)"; /* the same, and a suite's mark made */
/* Before each of v3's suites the words the cases before it defined go, as v3's run_test_suite puts back LATEST and /* Before each of v3's suites the words the cases before it defined go, as v3's run_test_suite puts back LATEST and
* HERE (and nothing else: SCR, BASE and the rest stay as the cases left them). A mark, (POST), is made at a suite's * HERE (and nothing else: SCR, BASE and the rest stay as the cases left them). A mark, (POST), is made at a suite's
* start and forgotten at the next's: FORGET takes the dictionary, the word IDs and the kernel's records of them. A * start and forgotten at the next's: FORGET takes the dictionary, the word IDs and the kernel's records of them. A
* case that raised the fence above the mark (FENCE) has its FORGET refused, and the next mark is made above it. */ * case that raised the fence above the mark (FENCE) has its FORGET refused, and the next mark is made above it.
static const char *const put_back[] = { "DECIMAL FORTH DEFINITIONS", "FORGET (POST)", "CREATE (POST)" }; * The forgetting is a line of its own; the mark is made by the state line of the suite's first case run (a case of
* the kernel's words, not run on the hosted product, passes it on): the fewest lines, for a boot's time. */
static const char put_back[] = "DECIMAL FORTH DEFINITIONS FORGET (POST)";
static unsigned length(const char *s) static unsigned length(const char *s)
{ {
@@ -48,6 +51,7 @@ int v4_post_run(const v4_post_host *h, const v4_post_case *cases, unsigned count
static v4_cell left[V4_DATA_DEPTH]; /* what it left on the stack, the top first: all of it, to compare (#189: v3's static v4_cell left[V4_DATA_DEPTH]; /* what it left on the stack, the top first: all of it, to compare (#189: v3's
cases leave 101); SHOWN_STACK of it shown */ cases leave 101); SHOWN_STACK of it shown */
unsigned i, k; unsigned i, k;
int mark = 0; /* a suite has begun and its mark is not yet made */
tally->tests = 0; tally->pass = 0; tally->fail = 0; tally->tests = 0; tally->pass = 0; tally->fail = 0;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@@ -58,8 +62,9 @@ int v4_post_run(const v4_post_host *h, const v4_post_case *cases, unsigned count
/* a suite begins: what the cases before it defined goes, as v3 does after each suite */ /* a suite begins: what the cases before it defined goes, as v3 does after each suite */
if (c->expect & V4_POST_SUITE) { if (c->expect & V4_POST_SUITE) {
for (k = i ? 0u : 2u, how = 0; how >= 0 && k < 3u; k++) /* the first suite: only the mark */ how = 0;
how = h->line(h->self, put_back[k], length(put_back[k]), out, V4_POST_OUT, &len); if (i > 0) how = h->line(h->self, put_back, (unsigned)sizeof put_back - 1u, out, V4_POST_OUT, &len);
mark = 1;
if (how < 0) { if (how < 0) {
say(h, "POST: the node did not come back from putting the dictionary back before "); say(h, c->name); say(h, "POST: the node did not come back from putting the dictionary back before "); say(h, c->name);
say(h, "; "); say_number(h, (long long)(count - i)); say(h, " not run\n"); say(h, "; "); say_number(h, (long long)(count - i)); say(h, " not run\n");
@@ -71,7 +76,9 @@ int v4_post_run(const v4_post_host *h, const v4_post_case *cases, unsigned count
/* every case starts from the same state */ /* every case starts from the same state */
v4_dstack_reset(&h->n->ds); v4_dstack_reset(&h->n->ds);
how = h->line(h->self, state_line, (unsigned)sizeof state_line - 1u, out, V4_POST_OUT, &len); if (mark) how = h->line(h->self, state_mark, (unsigned)sizeof state_mark - 1u, out, V4_POST_OUT, &len);
else how = h->line(h->self, state_line, (unsigned)sizeof state_line - 1u, out, V4_POST_OUT, &len);
mark = 0;
if (how < 0) lost = 1; if (how < 0) lost = 1;
if (how != V4_TEXT_COMPLETED) { /* what the node said of it is what is shown */ if (how != V4_TEXT_COMPLETED) { /* what the node said of it is what is shown */
came_back = 0; no_state = 1; came_back = 0; no_state = 1;