Skip to content

LATX, opt: Reduce AOT page-load link capacity - #340

Draft
LaurenIsACoder wants to merge 4 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/aot-link-capacity
Draft

LATX, opt: Reduce AOT page-load link capacity#340
LaurenIsACoder wants to merge 4 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/aot-link-capacity

Conversation

@LaurenIsACoder

Copy link
Copy Markdown
Contributor

Summary

  • reduce the initial AOT link table for page-load mode from 100000 entries to 512
  • keep load-all mode at 100000 entries
  • grow the table geometrically while preserving existing entries
  • make growth overflow-safe and degrade to unlinked TBs on allocation failure instead of terminating the process

Review fixes

The original patch was corrected during review:

  • align the page-mode capacity with the documented 512 entries (the patch used 128)
  • replace magic mode/capacity values with named constants
  • use size_t for capacities and indices
  • guard doubling against overflow
  • use g_try_renew() and skip additional AOT links on growth failure, preserving the old allocation and capacity

Validation

Validated on LoongArch host l1 at 06965c246dc431a01651ab6598784565b68c71f8:

  • O1+AOT latx-x86_64 target build: PASS (397/397 on initial build)
  • full product build: PASS
  • GDB white-box capacity check: page mode starts at 512; insertion 513 grows to 1024 with entries 1, 512, and 513 preserved; load-all mode remains 100000
  • sizeof(aot_link_info) == 24: page-mode initial allocation drops from 2,400,000 bytes to 12,288 bytes
  • deterministic RED: old overflow path exits the process with code 1
  • deterministic GREEN: fixed overflow path emits one warning and returns without terminating the process
  • explicit test build and Meson tests: 4/4 PASS
  • restored default product configuration: registered tests [], full build PASS

Mac-side final checks:

  • four-commit series checkpatch.pl --strict: 0 errors, 0 warnings
  • git diff --check: clean
  • Standards review: PASS, no P0-P2 findings remaining
  • Spec review: PASS, no P0-P2 findings remaining

ganjue66da and others added 4 commits July 24, 2026 08:31
when loading by page, the total number of aot_global_info_total entries
is typically not large, so setting the initial capacity to 512 is more
appropriate.

Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
The page-loading path used 128 entries even though the optimization specifies an initial capacity of 512. The capacity selection also encoded the load-all mode and both sizes as magic numbers.

Name the AOT mode and capacities, use 512 for page loading, and retain 100000 entries for load-all mode.

Test: source consistency check verifies page=512 and segment=100000.
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Reducing the initial link-table capacity makes dynamic growth a normal path. The table used signed counters, shifted the capacity without an overflow guard, and assigned realloc directly back to the only pointer.

Use size_t counters, typed GLib allocation, and reject capacity overflow before doubling.

Test: strict checkpatch and source guard checks; LoongArch growth/build validation follows.
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
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