Skip to content

LATX, opt: Separate PE AOT caches by load address - #342

Draft
LaurenIsACoder wants to merge 9 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/aot-pe-load-address-v2
Draft

LATX, opt: Separate PE AOT caches by load address#342
LaurenIsACoder wants to merge 9 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/aot-pe-load-address-v2

Conversation

@LaurenIsACoder

Copy link
Copy Markdown
Contributor

Summary

  • Use a versioned, type-qualified AOT cache identity and include the full segment address for PE/CACHE mappings.
  • Apply the same identity to generation, locking, merge, publication, loading, and the in-memory library tree.
  • Build AOT paths with bounds checks and release address-specific mappings when their segment is removed.
  • Keep segment runtime flags independent from the AOT file type.
  • Add focused coverage that is built only when tests are explicitly enabled.

Compatibility

Existing unqualified AOT cache files are not reused by the v2 identity and will be rebuilt. This prevents stale caches from blocking or merging with address-specific caches.

Dependency

This branch is based on #341. The PR diff will shrink to the single 0005 commit after #341 merges.

Validation

Validated on LoongArch host l1 at c8d27d69f37a151433bbe0ffe9167f1120388f1e:

  • Deterministic RED before the implementation, followed by GREEN for test-latx-aot-pe-load-address.
  • Affected segment.c, aot.c, aot_lib.c, and aot_merge.c objects compile successfully.
  • Explicit test build completes; Meson tests pass 6/6.
  • Default tests=disabled product build completes.
  • The normal product build does not generate the focused test executable.
  • git diff --check passes; checkpatch reports no errors.

ganjue66da and others added 9 commits July 24, 2026 12:13
Replace file overwrites with atomic rename operations.

Eliminate locks during AOT file reading.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix LATX AOT cache generation when temporary-file writes or publication fail.

Write to an exclusive .tmp file, sync its contents, rename it over the final path, and sync the parent directory. Failure-injection coverage verifies that write and rename errors preserve the current final file.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix LATX lock-free readers invalidating a cache that a writer replaced concurrently.

Take the writer lock and compare the opened and current inode before unlinking an invalid cache. The regression test covers both replaced and unchanged files.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix non-TU LATX AOT merges overwriting the final cache in place.

Write the merged image to the same exclusive temporary path and let the outer publication step replace the final file atomically.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Fix LATX AOT builds where configuration headers expose bool with a different underlying type across translation units.

Use int for the cross-file generation status while preserving boolean success semantics. The AOT-enabled non-TU affected objects compile with this declaration.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Add regression coverage for post-rename durability failures, legacy cache fragments, and stale temporary-file reclamation.

The test runs only through the explicit LATX test configuration.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Publish a generated temporary file only when there is no prior cache or when the merge completed successfully. Preserve the current cache on load, validation, or merge failures.

Remove deprecated A/B fragments under the writer lock, account stale .tmp files in cache reclamation, and report post-rename directory-sync failures without hiding the successful namespace update.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Allow LATX AOT caches with a deterministically invalid length or version trailer to recover under the writer lock.

Keep the current file unchanged for transient open, seek, read, temporary-file, or merge failures.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Use a versioned, type-qualified cache identity for AOT files and include the full segment address for PE and cache mappings. Apply that identity consistently to generation, locking, merging, publication, loading, and the in-memory library tree.

Build cache paths with bounds checks, keep runtime segment state separate from the AOT file type, and release address-specific cache mappings when their segment is removed.

Add focused coverage for identity namespacing, distinct and same-page PE addresses, independent state/type fields, and lib-tree removal. Keep the test target out of normal product builds.

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