-
-
Notifications
You must be signed in to change notification settings - Fork 669
Utilize lowMemoryUnused #1103
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
Utilize lowMemoryUnused #1103
Conversation
From the fixtures it actually seems that the only place where this does something useful is in the |
I'm wondering could we decrease 1024 bytes to 256 bytes which potentially enough for most of usual cases but more economical in terms of RAM consumption which is pretty important for IoT for example? I saw binaryen hardcoded this values in enum |
Yeah, the value is currently hardcoded, but I guess it wouldn't be too hard to make it configurable. Might well be that we can get away with a much smaller value, as this really just appears to affect manual unsafe code. Even if we'd have huge classes with lots of fields, these would already use offsets anyway. Currently thinking that we'd not do this optimization at all if |
Yeah, we have a lot of handcrafted optimizations and low-level stuffs but for external user this optimization pass could be useful. Also it close this most oldest issue at last! =) |
Not so sure about the old issue. Seems to be quite limited to |
PR for inlining limits: WebAssembly/binaryen#2655 |
That's inlining PR will be really useful for our needs! |
@dcodeIO it seems this optimization pass significant slowdown compilation but with pretty small benefits at least for our tests so I suggest apply it only for optimizeLevelHint >= 3. wdyt? |
Yeah, turned out that our tests are relatively immune to this because stdlib loads and stores are optimized already. More about user code where |
I made pr for this: #1169 |
in that tuned PR tests run in |
This PR investigates utilizing the
lowMemoryUnused
option provided by Binaryen, doing (techically unsafe) optimizations liketo
In order to do this, the first 1KB of memory must be guaranteed to be invalid, since the 32-bit addition in the first snippet can overflow while the
offset=
attribute cannot. As a result, pointer additions below the 1024 bytes threshold can be optimized.On a first glimpse this doesn't help us a lot since the compiler already emits
offset=
for field accesses, with just a few, yet important cases where it helps, especially within stdArrayBuffer
andArray
(which is expected), making it more a micro optimization for speed than anything else.