Skip to content
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

Optimize data section parsing and storage #1024

Merged
merged 13 commits into from May 9, 2024
Merged

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented May 9, 2024

Benchmarks revealed that parsing and handling of data sections were a big contributor to the overall spent time for some benchmarks, such as ffmpeg.wasm. This is probably due to heap memory allocator pressure since all of its many data segments each allocated a bit of heap memory for their bytes.
This PR bundles bytes of all active data segments into a single buffer reducing the overall memory consumption and pressure on the heap memory allocator.
Benchmarks show roughly 15% improvement for compiling ffmpeg.wasm in lazy compilation mode.

Robbepop added 10 commits May 8, 2024 21:33
Active data segments now store all their bytes into a common buffer to avoid having many small allocations.
This leads to smaller indices which mades it possible to only store u32 instead of usize decreasing the size_of<DataSegment> by 8 bytes in total.

Also applied rustfmt and added missing docs.
Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 75.26882% with 23 lines in your changes are missing coverage. Please review.

Project coverage is 80.77%. Comparing base (30ca773) to head (957cc9f).

Files Patch % Lines
crates/wasmi/src/module/data.rs 80.76% 10 Missing ⚠️
crates/wasmi/src/memory/data.rs 53.33% 7 Missing ⚠️
crates/wasmi/src/module/instantiate/mod.rs 66.66% 5 Missing ⚠️
crates/wasmi/src/module/builder.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1024      +/-   ##
==========================================
- Coverage   80.80%   80.77%   -0.03%     
==========================================
  Files         269      269              
  Lines       24736    24786      +50     
==========================================
+ Hits        19989    20022      +33     
- Misses       4747     4764      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Robbepop Robbepop merged commit 6214e51 into master May 9, 2024
15 of 17 checks passed
@Robbepop Robbepop deleted the rf-opt-data-section-parsing branch May 9, 2024 08:12
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.

None yet

1 participant