Skip to content

perf(english): name the lemma table so it lazy-loads - #224

Merged
ddehilster merged 1 commit into
VisualText:mainfrom
ddehilster:perf/english-lemmas-lazy-name
Sep 22, 2026
Merged

ddehilster merged 1 commit into
VisualText:mainfrom
ddehilster:perf/english-lemmas-lazy-name

Conversation

@ddehilster

Copy link
Copy Markdown
Member
en-lemmas.kbb  ->  en-lemmas-full.kbb

The engine loads a knowledge base word by word, on demand, only when the file name ends in full before the extension. This one did not, so 2 MB was read whole at startup to serve a few dozen lookups.

Not breaking, despite two analyzers depending on this table

loadkbb resolves against the analyzer's own kb/user directory, and EnglishPhrases and StatuteFrames each vendor their own copy — so the library's file name is not what they load. Verified by running EnglishPhrases with its vendored copy renamed while the library file still had the old name: it loaded and answered normally.

What this rename does is let an analyzer vendor the file under a name that lazy-loads. That is where the gain is:

analyzer run 5.32 s → 0.70 s on a 60-word input
phrases.txt byte-identical across all 52 inputs
lemmas resolved 749 either way

So the lazily loaded table answers every lookup the eager one did; what goes away is reading 2 MB to serve a few dozen words. The analyzers keep working until they re-vendor, and get the speedup when they do.

The file is regenerated rather than moved, so the header inside it names the file it now is. Its content is otherwise unchanged.

With this, languages/English has en-nouns.dict (2 MB) and en-roots.kbb (4 MB) left eager — neither is loaded into an analyzer anywhere in this repository, so neither rename can be verified by a run. lazyload.md records that.

🤖 Generated with Claude Code

en-lemmas.kbb -> en-lemmas-full.kbb

The engine loads a knowledge base word by word, on demand, only when the file
name ends in "full" before the extension.  This one did not, so 2 MB was read
whole at startup to serve a few dozen lookups.

NOT breaking, despite renaming a file two analyzers depend on.  loadkbb
resolves against the ANALYZER's own kb/user directory, and EnglishPhrases and
StatuteFrames each vendor their own copy of this table, so the library's file
name is not what they load.  Verified by running EnglishPhrases with its
vendored copy renamed while the library file still had the old name: it loaded
and answered normally.  What the rename does is let an analyzer vendor the file
under a name that lazy-loads, which is where the gain is:

  analyzer run   5.32 s -> 0.70 s   on a 60-word input
  phrases.txt    byte-identical across all 52 inputs
  lemmas found   749 either way

so the lazily loaded table answers every lookup the eager one did.  The
analyzers keep working until they re-vendor, and get the speedup when they do.

The file is regenerated rather than moved, so the header inside it names the
file it now is.  Its content is otherwise unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ddehilster
ddehilster merged commit a23eff6 into VisualText:main Sep 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant