Skip to content

Load frametables of dynlink'd modules in batch#11935

Merged
dra27 merged 6 commits intoocaml:trunkfrom
stedolan:dynlink-frametables
Jan 27, 2023
Merged

Load frametables of dynlink'd modules in batch#11935
dra27 merged 6 commits intoocaml:trunkfrom
stedolan:dynlink-frametables

Conversation

@stedolan
Copy link
Copy Markdown
Contributor

Each Dynlinked cmxs file may contain many modules, all with their own frametables. Currently, each module is registered and initialised one at a time, rebuilding the frame table each time. This patch changes it to register all of the frame tables in bulk, and then initialise all of the modules.

I also added some more error checking - currently, Dynlink silently ignores missing frametables, which seems bad. It turns out that the gc_roots symbol was always missing for shared_startup blocks (where it's not necessary), so I changed asmlink to unconditionally include an empty gc_roots block in this case, as that seems cleaner than having this special case.

Copy link
Copy Markdown
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo a possible code comment and a make promote is needed in the testsuite

let units = List.map (fun (info,_,_) -> info) units_list in
List.iter compile_phrase (Cmm_helpers.generic_functions false units);
List.iter compile_phrase
(Cmm_helpers.emit_preallocated_blocks []
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the testsuite will guard against this actually regressing, I think it's worth adding a comment as to why the call to emit_preallocated_blocks is made?

Copy link
Copy Markdown
Contributor

@gadmm gadmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. (I cannot comment on the changes to asmlink.ml though, which look unrelated.)

@stedolan
Copy link
Copy Markdown
Contributor Author

The changes to asmlink are the bit that ensures all modules have a (possibly empty) gc_roots section, instead of having a special case for startup files.

@gadmm
Copy link
Copy Markdown
Contributor

gadmm commented Jan 26, 2023

I was unclear with my comment. Only for this bit I did not look deeper on the change because I am less familiar with this part of the compiler, but this still looks good to me, thanks to your helpful explanation in the PR description.

@dra27 dra27 merged commit 33699c8 into ocaml:trunk Jan 27, 2023
gasche pushed a commit to gasche/ocaml that referenced this pull request Feb 3, 2023
@kayceesrk kayceesrk added the Performance PR or issues affecting runtime performance of the compiled programs label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance PR or issues affecting runtime performance of the compiled programs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants