-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Extend simplified write barrier elimination to work inter-block (not just intra-block) #39164
Comments
@sjindel-google The write barrier is a big code size contributor. This could be something to investigate. Please self-assign if you want to look into it. |
Besides looking across blocks, another impediment to write barrier elimination is instructions which can interrupt it because they might trigger GC (calls, allocations, boxes, etc.) We've discussed two approaches to extending WBE across these kinds of instructions: Reserved allocationsSeveral consecutive allocations are "batched", where the first allocation (or an instruction at the beginning) ensures there's enough room in new-space for the consecutive allocations. If there isn't it can (for example) trigger a new-space collection to make room. For example:
Add live temporaries to store bufferWe assume that any temporary defined by an allocation will be either in new space or in the store buffer until the next call. So, the IL would simply look like:
After any collection completes, we scan the stack a second time, and add all live temporaries in frames immediately above an exit frame into the store barrier. This restores the original assumption. This approach would allow us to remove the store barrier in more cases (for example, across Box instructions) and would not require code for the reserve operation. However, it could extend the lifetimes of some objects longer than necessary. /cc @rmacnak-google @mraleph @alexmarkov What do you think? |
Inter-block WBE (without either of the extensions above) produces 0.13% Flutter Gallery reduction on ARM64 and 0.15% on ARM. |
Inter-block WBE with the "Add live temporaries to store buffer" approach reduces FG code size by 0.88% on ARM64 and 0.98% on ARM. |
"Reserved allocations" is similar to an optimization in V8 where some allocations are fused and the GC sees one larger allocation that the caller then divides up. Overall I like "Add live temporaries to store buffer". Here I'm a bit worried about creating too much remembered set work, but I think if we exclude the allocation of arrays from the optimization, there shouldn't be too much extra to visit. Hopefully from a code size perspective the interesting allocations sites will be for small, fixed-size objects. Also, if in addition to adding these values to store buffer, we add them to the deferred marking queue, we might no longer need the EnsureIsNewOrRemembered logic at the end of the allocation stubs. |
Inter-block WBE with the "Reserved allocations" approach (V8-style) will yield at most 0.42% on ARM64 and 0.47% on ARM. The actual gain will be noticeably less because I didn't account for the extra instructions needed to perform the reserve operation. |
If I exclude arrays from "Add live temporaries to store buffer", the code size gain is unchanged. |
This reverts commit e5a2271. Reason for revert: We are seeing some crashes on the bot see https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-linux-debug-x64/8684 Original change's description: > [vm] Aggressive write-barrier elimination. > > Flutter Gallery code size total: > -0.88% on ARM64 > -0.98% on ARM > > Fixes #39164. > > Change-Id: I8e65b1209ef1150bb73f3474506ebc97d7ab3685 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132003 > Reviewed-by: Ryan Macnak <rmacnak@google.com> > Commit-Queue: Samir Jindel <sjindel@google.com> TBR=kustermann@google.com,rmacnak@google.com,sjindel@google.com Change-Id: Ia93b43a423ee982aea550eb9fc24d34509db3dce No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135421 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
Right now our write-barrier elimination is very simple and works only inside one block:
To eliminate more barriers, we might want to extend this to work across basic blocks.
/cc @mraleph
The text was updated successfully, but these errors were encountered: