Skip to content

Update #2151 to post .NET 10#5530

Draft
lisandroct wants to merge 6 commits into
masterfrom
lisandro/update-2151
Draft

Update #2151 to post .NET 10#5530
lisandroct wants to merge 6 commits into
masterfrom
lisandro/update-2151

Conversation

@lisandroct

@lisandroct lisandroct commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Re-implements #2151 on top of latest master and .NET 10 support.

Reuse C# runtime buffers when consuming BytesSource values from module FFI exports instead of allocating fresh byte arrays for each call.

It's reasonable and the benchmarks results are enticing. These changes obviously make sense as long as Wasm module execution stays single-threaded. If future module execution becomes concurrent (or we re-enter these exports recursively), these buffers become unsafe.

I ran the benchmarks two times (with high variability in some cases):

Benchmark Master This Branch Delta
large args 64KiB 48.648 us / 47.275 us 40.893 us / 42.611 us -15.94% / -9.87%
circles load=10 34.706 ms / 34.631 ms 33.170 ms / 33.325 ms -4.43% / -3.77%
circles load=100 34.624 ms / 34.500 ms 33.296 ms / 33.163 ms -3.84% / -3.88%
ia_loop load=10 10.271 ms / 10.362 ms 9.946 ms / 10.056 ms -3.16% / -2.96%
ia_loop load=100 26.831 ms / 27.533 ms 25.543 ms / 25.627 ms -4.80% / -6.92%
filter string index 48.699 us / 43.832 us 49.177 us / 46.586 us +0.98% / +6.28%
filter u64 index 21.535 us / 21.278 us 25.251 us / 21.471 us +17.26% / +0.91%
insert u32/u64/u64 btree 305.730 us / 247.585 us 293.044 us / 247.641 us -4.15% / +0.02%
iterate u32/u64/str 49.282 us / 42.789 us 41.700 us / 40.554 us -15.39% / -5.22%
iterate u32/u64/u64 21.775 us / 18.167 us 15.486 us / 15.167 us -28.88% / -16.51%

The results are good (negative numbers mean faster execution) in all benchmarks except filter string index, filter u64 index and maybe insert u32/u64/u64 btree. They don't match the original branch results. I assume this comes down to a difference in hardware and .NET SDK version (I ran the benchmarks on .NET 10 with NativeAOT-LLVM).

These changes are probably worth applying.

API and ABI breaking changes

No breaking changes.

Expected complexity level and risk

  1. I don't see a lot of risk as long as all tests pass, because it's not adding new functionality.

Testing

  • Tests are passing.

@lisandroct
lisandroct marked this pull request as draft July 13, 2026 14:45
@lisandroct
lisandroct force-pushed the lisandro/update-2151 branch from 3f48f07 to c870594 Compare July 17, 2026 13:58
@lisandroct
lisandroct force-pushed the lisandro/update-2151 branch from c870594 to 060c27f Compare July 17, 2026 19:36
@lisandroct
lisandroct force-pushed the lisandro/update-2151 branch from 060c27f to 90a56af Compare July 17, 2026 19:49
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.

1 participant