Skip to content

binary search the dispatch lookup when ranges are irregular - #35

Open
dougchansan wants to merge 1 commit into
ExpansionPak:mainfrom
dougchansan:fix/dispatch-search-lookup
Open

dougchansan wants to merge 1 commit into
ExpansionPak:mainfrom
dougchansan:fix/dispatch-search-lookup

Conversation

@dougchansan

Copy link
Copy Markdown
Contributor

40637c4 started splitting llvm ranges at function boundaries. the default dispatch lookup only collapses equal-stride runs, so dolrecomp_find_original went from 2 checks to ~7000 sequential ones, and it runs on every return to the runner. llvm modules ended up 7-30x slower than the c backend, and mkdd race.sav hung.

this emits a sorted table and binary searches it once there are more than 16 runs. a small number of runs keeps the existing linear form. overlapping ranges also stay linear to keep first-match order. a coverage guard in the old address >= ... && address < ... form rejects out-of-range addresses first, and keeps module-table generators that scrape it working.

frames in 20s, recompcore runtime:

before after c
luigi's mansion foyer 70 834 566
mkdd race 0 (hung) 1080 1066
skyward sword gameplay 23 876 921

added tests in test_dispatch.c.

40637c4 splits llvm ranges at every function boundary, so the linear
dispatch lookup grew from 2 checks to ~7000 per dispatch. emit a sorted
table and binary search it once there are more than 16 runs.
@dougchansan
dougchansan force-pushed the fix/dispatch-search-lookup branch from 639e19e to 081fb52 Compare October 10, 2026 21:14
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