Skip to content

wasm2c: Alter how segments are loaded #2555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

squk
Copy link
Contributor

@squk squk commented Mar 5, 2025

This reduces the number of usages of the LOAD_DATA macro from the number of segments to one. For large binaries, this greatly reduces the amount of memory required to compile the library

@squk squk force-pushed the fix/data_segments branch 2 times, most recently from 6d71aff to 8e29f65 Compare March 5, 2025 22:19
@squk squk force-pushed the fix/data_segments branch from 8e29f65 to f1c33fa Compare March 5, 2025 22:20
@squk squk changed the title Alter how segments are loaded wasm2c: Alter how segments are loaded Mar 5, 2025
for (int i = 0; i < sizeof(active_data_segment_data_ptrs) / sizeof(active_data_segment_data_ptrs[0]); i++) {

LOAD_DATA(instance->w2c_memory, active_data_segment_offsets[i], active_data_segment_data_ptrs[i], active_data_segment_sizes[i]);
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why the compiler was using more memory in the old form? Is it because of inlining somehow?

That amount of static data here is the same right? Does the program you are having trouble with contains a huge about of segments?

@shravanrn
Copy link
Collaborator

If possible, if you have a simple benchmark that you are using measure compile time for a wasm module with lots of segment data, that would be great to include in the benchmarks folder as well.

@sbc100
Copy link
Member

sbc100 commented Mar 19, 2025

If possible, if you have a simple benchmark that you are using measure compile time for a wasm module with lots of segment data, that would be great to include in the benchmarks folder as well.

We tracked this down offline to the use of -Wthread-safety-analysis in clang when compiling the generated code. Its not clear yet if this is bug.. but we should probably hold off landing this until we figure it out.

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.

3 participants