Skip to content

Improve locality of strings in WRIT chunk - #357

Merged
dstelzer merged 2 commits into
Dialog-IF:mainfrom
sehugg:writ-reorder
Sep 16, 2026
Merged

dstelzer merged 2 commits into
Dialog-IF:mainfrom
sehugg:writ-reorder

Conversation

@sehugg

@sehugg sehugg commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

The analyze_strings() function sorts all strings by ascending size, so they can be placed in short/medium/long tiers for encoding. This scatters related strings uniformly across the WRIT chunk, which means the 8-bit platforms have to read more pages. One good example is the intro text, which might be scattered across 5 different pages.

The fix is to still do the initial sort, but then we re-sort the medium and long tiers back into their original index order. Thus every string stays in the same tier, but locality is improved. This reduces WRIT chunk reads by about 30 percent on 6502 platforms.

@dstelzer

Copy link
Copy Markdown
Contributor

Brilliant!

@dstelzer
dstelzer merged commit 57fe35e into Dialog-IF:main Sep 16, 2026
5 checks 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.

2 participants