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
+12 -5
View File
@@ -13,11 +13,14 @@
#define SHOWN_STACK 32u /* and how many of the values it left */
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
* 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
* 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)" };
* case that raised the fence above the mark (FENCE) has its FORGET refused, and the next mark is made above it.
* 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)
{
@@ -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
cases leave 101); SHOWN_STACK of it shown */
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;
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 */
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 = h->line(h->self, put_back[k], length(put_back[k]), out, V4_POST_OUT, &len);
how = 0;
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) {
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");
@@ -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 */
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 != V4_TEXT_COMPLETED) { /* what the node said of it is what is shown */
came_back = 0; no_state = 1;