Commit Graph

303 Commits

Author SHA1 Message Date
Samir Jindel 4c6a2ab47c Re-land "[vm] Aggressive write-barrier elimination."
Three bugs were fixed:

1. BitVector::Equals was not fully fixed by the original CL.
2. We need to add old objects to the deferred marking queue during
   RememberLiveTemporaries().
3. The thread being scanned in RestoreWriteBarrierInvariant may not
   be scheduled, so we cannot use its store buffer block.

In addition, this changed uncovered another bug fixed in:
https://dart-review.googlesource.com/c/sdk/+/138960.

Original CL is in patchset 3.

This reverts commit 30a12a349e.

Change-Id: I36169b09563998ed5b3c3eac70ee0ebe78853e62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2020-03-11 13:05:59 +00:00
Samir Jindel 40cd5fc5f6 [vm, gc] Avoid double-enqueuing WeakProperties when they end up in the deferred marking list.
Change-Id: Iac3a30aaaf2c2b513d8e39b3bef787462fd91c6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138960
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-03-10 23:04:48 +00:00
Martin Kustermann 30a12a349e Revert "Re-land "[vm] Aggressive write-barrier elimination.""
This reverts commit eff1a9ff97.

Reason for revert:
  Causes flaky hits of RELEASE_ASSERT in marker.cc, see b/151131634.

Original change's description:
> Re-land "[vm] Aggressive write-barrier elimination."
> 
> The original revision is in Patchset 3.
> 
> Four bugs were fixed:
> 
> 1. JoinEntryInstr::SuccessorCount() is not the correct way to get the
>    number of successor blocks from the Join block;
>    JoinEntryInstr::last_instruction()->SuccessorCount() must be used
>    instead.
> 
> 2. BitVector::Equals() was non-deterministically returning 'false'
>    for equal vectors.
> 
> 3. All blocks need to be processed at least once during the Analysis
>    phase (not only in the SaveResults phase).
> 
> 4. We were not removing write barriers from StoreIndexed instructions,
>    even though we had support for it.
> 
> This reverts commit 7fd8ad5a2d.
> 
> Fixes https://github.com/dart-lang/sdk/issues/40780
> 
> Change-Id: I9650ec2c547ec49cf88ca0524e14f6c245621f6a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138086
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=kustermann@google.com,rmacnak@google.com,sjindel@google.com

Change-Id: If9afd84465175fad2431405a97e9293c8bd5e476
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138808
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-03-10 10:15:30 +00:00
Samir Jindel eff1a9ff97 Re-land "[vm] Aggressive write-barrier elimination."
The original revision is in Patchset 3.

Four bugs were fixed:

1. JoinEntryInstr::SuccessorCount() is not the correct way to get the
   number of successor blocks from the Join block;
   JoinEntryInstr::last_instruction()->SuccessorCount() must be used
   instead.

2. BitVector::Equals() was non-deterministically returning 'false'
   for equal vectors.

3. All blocks need to be processed at least once during the Analysis
   phase (not only in the SaveResults phase).

4. We were not removing write barriers from StoreIndexed instructions,
   even though we had support for it.

This reverts commit 7fd8ad5a2d.

Fixes https://github.com/dart-lang/sdk/issues/40780

Change-Id: I9650ec2c547ec49cf88ca0524e14f6c245621f6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138086
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-03-09 14:37:27 +00:00
Ryan Macnak 2a8127dbfa [vm, gc] Take heap size into account when deciding when to start concurrent marking.
Begin concurrent marking when available space in old-space is less than 5% or than the size of new-space, whichever comes first.

Avoids concurrent marking starting too late in larger heaps, where the program would exceed the hard threshold before concurrent marking would finish.

Change-Id: I6a1991331a1450ffa647bf0e21dfc19e82537268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134466
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-03-05 17:49:54 +00:00
Ryan Macnak df5036eb6e [vm] Require only an isolate group, not an isolate, in Dart_Delete[Weak]PersistentHandle.
Remove the now-misleading isolate parameter of Dart_DeleteWeakPersistentHandle.

Bug: https://github.com/dart-lang/sdk/issues/40836
Change-Id: I784f1ecf564484b59f60ebef53ddb975aff1bd23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138015
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-03-04 18:56:16 +00:00
Ryan Macnak 608604589c [vm, gc] Fix a lock order inversion detected by TSAN.
If a thread acquires both a freelist lock and the pages lock, ensure it acquires the freelist lock first.

Bug: https://github.com/dart-lang/sdk/issues/39611
Change-Id: Iadd7c270e18052aa32d883db1ddb8e4ebd1f0c49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138041
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-03-03 18:30:23 +00:00
Ryan Macnak e211bd28c1 [vm, gc] Set the current isolate to the group's only member before running finalizers.
Some embedder code relies on the presence of a current isolate equal to the isolate that created the handle. This code will be need to be updated to be isolate-group aware before we can run finalizers only in the context of the isolate group instead of an isolate.

Bug: https://github.com/dart-lang/sdk/issues/40836
Change-Id: I38956c556df551e48ee7e4d0822aa5def8dc4fc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138013
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-03-02 22:56:06 +00:00
asiva 09bbd3cca5 [VM/concurrency] - Temporary workaround for issue https://github.com/dart-lang/sdk/issues/40836
Change-Id: I4369c717122ef7b84c5931b8fb3edf18fb433375
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137880
Reviewed-by: Jason Simmons <jsimmons@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-02-29 02:16:10 +00:00
Ryan Macnak d99f6bffcb [vm, test] Fix false positive from MSAN during vm/cc/StoreIntoObject.
Change-Id: I3133420863b50734349646b3d6ad04df819ed322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137657
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-28 00:55:50 +00:00
Ryan Macnak 2a5d0589ac [vm, gc] Verify the store buffer contains all old-space objects that reference new-space objects.
Speed-up ObjectSets.

Fix pointer verification before and after scavenging to set the correct mark expectation being on concurrent marking state.

Bug: https://github.com/dart-lang/sdk/issues/40780
Change-Id: Ic7ce6d5a829e41634083b0c274b9764da3f4b619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137240
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-27 19:26:33 +00:00
Ryan Macnak 60c86a4009 [vm, gc] Fix races related to Scavenger::AddAbandonedInBytes and UsedInWords.
[infra] Run fewer tests under TSAN. TSAN has a significantly higher overhead than the other sanitizers.

Change-Id: I92b69923e93fa4634168352bdbe30d6ee7e7f72d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137402
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-27 18:01:13 +00:00
Clement Skau 9c05fde96b [Cleanup] Removes deprecated --gc_at_instance_allocation.
The flag only appears in two tests and a comment.
Flag was removed in https://dart-review.googlesource.com/c/sdk/+/83120

Change-Id: I2a5d828c8ec7909a3d16579f9a9771176aabb65e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136974
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-02-26 15:00:26 +00:00
Ryan Macnak 7fd8ad5a2d Revert "[vm] Re-land aggressive write-barrier elimination."
This reverts commit c7d7552697.

Reason for revert: https://github.com/dart-lang/sdk/issues/40780

Original change's description:
> [vm] Re-land aggressive write-barrier elimination.
> 
> It incorrectly assumed that all stores in Dart code write to Instances.
> There is actually one exception, Contexts, which do not inherit from Instance.
> 
> I've added asserts to ensure this kind of bug cannot resurface.
> 
> The original change is in patchset 4.
> 
> Change-Id: Ic2d8d05e70a4de738eb9fb5980487b4f27111b8c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136221
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=kustermann@google.com,rmacnak@google.com,sjindel@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I1891677b21560c7fc5a54a8eb800ef5850654402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137290
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-26 02:18:25 +00:00
Samir Jindel c7d7552697 [vm] Re-land aggressive write-barrier elimination.
It incorrectly assumed that all stores in Dart code write to Instances.
There is actually one exception, Contexts, which do not inherit from Instance.

I've added asserts to ensure this kind of bug cannot resurface.

The original change is in patchset 4.

Change-Id: Ic2d8d05e70a4de738eb9fb5980487b4f27111b8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136221
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-02-24 18:26:46 +00:00
Ryan Macnak 2a42699761 [vm, gc] Make use of the main thread during parallel GC phases.
Change-Id: I31c4c73cea3bc71472d0c81c7a4edebb492635a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126983
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-20 23:02:46 +00:00
Martin Kustermann dae308461c [vm/concurrency] Share [Heap] and [SharedClassTable] between all isolates within one isolate group
This CL:

  * Moves [Heap]/[SharedClassTable] from [Isolate] to [IsolateGroup], which
    will make all isolates in the group use the same heap. The GC will use
    the shared class table for object size information.

  * Adds support for entering/leaving an isolate group as a helper thread
    (e.g. via [Thread::EnterIsolateGroupAsHelper]). The current active
    isolate group can be accessed via TLS `IsolateGroup::Current()` or
    `Thread::isolate_group_`. When entering as a helper thread there will be
    no current isolate.

  * Changes the GC to use the above mechanism and ensures GC works without
    a currently active isolate. The GC will use information purely available via
    [IsolateGroup]. The GC will iterate all isolates within an isolate
    group e.g. for scanning roots.

  * Makes spawning of new isolates start in their own isolate group.
    Once the isolate is fully functional it's heap will be merged into
    the original isolate group

  * Moves ApiState, containing persistent and weak persistent handles,
    from [Isolate] to [IsolateGroup], plus adds appropriate locking.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ia8e1d8aa78750e8400864200f4825395a182c004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126646
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-02-20 21:08:35 +00:00
Alexander Aprelev 005e336de9 [vm/heap] Take into account abandoned bytes so new space grows appropriately.
Need for this was discovered while landing shared heap.

Change-Id: I95a27a5b8de51f94289ff67e2844279c189ea6c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135584
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-02-18 22:11:14 +00:00
Ben Konyi edc8bd7ec6 Revert "Re-land "[vm] Aggressive write-barrier elimination.""
Reason: Causing numerous DartFuzz crashes

This reverts commit 595038d19f.

Change-Id: I94e79cf1a3ddf9210a2929128cfc825bf47c92ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136260
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-02-18 17:12:21 +00:00
Samir Jindel 595038d19f Re-land "[vm] Aggressive write-barrier elimination."
DoubleToIntegerInstr was incorrectly marked with CanCallDart() = false.
Original CL is in patchset 3.
Fixes https://github.com/dart-lang/sdk/issues/40593

This reverts commit e7403c149a.

Change-Id: Ibb33fcf6480c820a10c968a2e22339afc5286035
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135310
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2020-02-17 14:47:15 +00:00
Ryan Macnak 35705086c5 [vm, gc] Remove dead path from promotion allocation.
The final TryAllocateDataLocked will consider all free list buckets and a new page. These cases are all covered by the preceding TryAllocateSmallLock (free list small buckets) and TryAllocateDataBumpLocked (free list large buckets and new pages), so this retry will always fail.

Change-Id: I9ba3174d588085130273ee6e7920888d3abca0ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135581
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-14 17:41:37 +00:00
Siva Annamalai e7403c149a Revert "[vm] Aggressive write-barrier elimination."
This reverts commit e5a22713b1.

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 https://github.com/dart-lang/sdk/issues/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>
2020-02-12 00:53:05 +00:00
Samir Jindel e5a22713b1 [vm] Aggressive write-barrier elimination.
Flutter Gallery code size total:
-0.88% on ARM64
-0.98% on ARM

Fixes https://github.com/dart-lang/sdk/issues/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>
2020-02-11 22:48:25 +00:00
Ryan Macnak 16782e6c17 [vm, gc] New-space alignment is not configurable.
Change-Id: I6bb1c3dab0319ac5d827c947f38cb6396d2f7d81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134809
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-07 01:08:34 +00:00
Ryan Macnak 68d178f223 [vm] Remove FLAG_support_service and FLAG_support_reload, superseded by PRODUCT define.
When these were originally added, we thought we would be able to use them in place of ifdefs and rely on the compiler optimizations and linker GC to remove things. This turned out not to reliably remove what we wanted removed, so we ended up with the ifdefs anyway.

Change-Id: I62e74d60d92b18a688b9dffaf77b1440c10a07ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134402
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-02-04 23:31:17 +00:00
Martin Kustermann e171ff4a6d [vm/concurrency] Speed up isolate communication via normal snapshotting
Do not lock forwarding table during snapshot writing:

This is a follow-up to [0], which made the [WeakTable] used during
snapshot writing per isolate. Since each isolate has it's own table
now, there's not reason to lock it during snapshot writing.

Furthermore we speed up RawObject::InVMIsolateHeap() which was super slow
due to locking "vm-isolate"'s page space and walking all pages.

[0] https://dart-review.googlesource.com/c/sdk/+/114858


Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: I783ea6083c199058e76895fcde38dc06af6991d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134299
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-02-04 20:46:36 +00:00
Ryan Macnak 1efba58d22 Reapply "[vm] Initialize large typed arrays only once."
Change-Id: I92eb6c96db97e0951ae34315ad8d744e06064b3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133764
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-03 17:22:05 +00:00
Ryan Macnak 24418e6c6d [vm, gc] Remove BumpAllocationScope.
This scope can sneak objects larger than kAllocatablePageSize directly into non-large heap pages.

This scope also holds a heap lock outside of the GC, which is likely to create issues when multiple isolates run on the same heap.

Change-Id: Ic56277c83ffccfe2e1396ed773dd30b8d172bbba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-03 17:22:05 +00:00
Victor Lima b68d95ec9e [vm] Reland support for real unboxed floating point fields in AOT
Issue https://github.com/dart-lang/sdk/issues/40404

Change-Id: Icfa801ff0640a6b27bb3c13d0b737c40452cbf7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133983
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-31 12:56:31 +00:00
Zichang Guo 162d6c5634 Revert "[vm] Add support for real unboxed floating point fields in AOT"
This reverts commit 9eb531bde4.

Reason for revert: Bots are red. Some tests are failing.

https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-obfuscate-linux-release-x64/6039

https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-android-release-arm_x64/957

Original change's description:
> [vm] Add support for real unboxed floating point fields in AOT
> 
> Non-nullable floating point fields (double, Float32x4, Float64x2)
> are fully unboxed in their classes.
> 
> A bitmap for each class was added to the shared class table in order to keep
> track of the pointers of the classes. Since all classes in Flutter Gallery
> have less than 64 fields, the bitmap is represented by a 64 bit integer and
> fields whose offset is more than 64 words are not unboxed.
> 
> The instance sizes and field offsets might change between target and host
> in cross-compilation, since the number of words used to store unboxed fields
> may differ.
> 
> dart-aot Xeon
> 
>   SplayLatency               -4.62%
>   SplayHarderLatency         -4.17%
>   NavierStokes               -2.20%
>   Tracer                      8.72%
>   ParticleSystemPaint         2.90%
>   NBodySIMD                   8.35%
>   NBody                      25.59%
> 
> With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable:
> 
> flutter arm-v8:
> 
>   gallery total size: -1%
> 
>   matrix_utils_transform_rect_perspective   -16.70% (less is better)
>   matrix_utils_transform_rect_affine        -31.82% (less is better)
>   matrix_utils_transform_point_perspective  -24.90% (less is better)
>   matrix_utils_transform_point_affine)      -27.26% (less is better)
>   rrect_contains_bench                      -4.719% (less is better)
> 
> Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824
> Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Samir Jindel <sjindel@google.com>

TBR=kustermann@google.com,rmacnak@google.com,sjindel@google.com,victoragnez@google.com

Change-Id: Ic73858f6adb7f55c4129d4f46ff4731b378cb634
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134020
Reviewed-by: Zichang Guo <zichangguo@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-01-30 18:13:28 +00:00
Ryan Macnak d67fbe525b [vm, gc] Base the growth policy on usage instead of capacity.
With concurrent sweeping, the amount of capacity freed by a major GC is not known at the time growth is evaluated. This consistently biases the policy into growing more than it would with an accurate capacity from stop-the-world sweeping.

This is more interesting for larger heaps and when there is a tighter memory limit.

For a very large dart2js compile
Max Heap Capacity: 13.057 -> 11.861 GB
     Compile Time:    545 -> 472 seconds

For dart2js self-compile
Max Heap Capacity: 1.343 -> 1.385 GB
     Compile Time:  43.4 -> 43.5 seconds

Bug: https://github.com/dart-lang/sdk/issues/21364
Change-Id: If047e22a9cd9da6b34c8e499a39fde97427a69b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133660
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-01-30 17:54:08 +00:00
Victor Lima 9eb531bde4 [vm] Add support for real unboxed floating point fields in AOT
Non-nullable floating point fields (double, Float32x4, Float64x2)
are fully unboxed in their classes.

A bitmap for each class was added to the shared class table in order to keep
track of the pointers of the classes. Since all classes in Flutter Gallery
have less than 64 fields, the bitmap is represented by a 64 bit integer and
fields whose offset is more than 64 words are not unboxed.

The instance sizes and field offsets might change between target and host
in cross-compilation, since the number of words used to store unboxed fields
may differ.

dart-aot Xeon

  SplayLatency               -4.62%
  SplayHarderLatency         -4.17%
  NavierStokes               -2.20%
  Tracer                      8.72%
  ParticleSystemPaint         2.90%
  NBodySIMD                   8.35%
  NBody                      25.59%

With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable:

flutter arm-v8:

  gallery total size: -1%

  matrix_utils_transform_rect_perspective   -16.70% (less is better)
  matrix_utils_transform_rect_affine        -31.82% (less is better)
  matrix_utils_transform_point_perspective  -24.90% (less is better)
  matrix_utils_transform_point_affine)      -27.26% (less is better)
  rrect_contains_bench                      -4.719% (less is better)

Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2020-01-30 13:45:08 +00:00
Martin Kustermann 9eb09b64be [vm/concurrency] Add locking for any access to [FixedCache].
The [FixedCache] will be accessible by multiple isolates within an isolate
group as well as the GC, so we add locking around it's accessors.

This is a preparation step for the shared heap.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ief113419b3f7a69eda02084ce36cef0e25984315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133580
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-01-29 11:46:50 +00:00
Ryan Macnak 52da0b14f1 Revert "[vm] Initialize large typed arrays only once."
This reverts commit 6fcee199af.

Reason for revert: Wrong size logic

Original change's description:
> [vm] Initialize large typed arrays only once.
> 
> Previously large (>256k) typed arrays would be initialized 3 times:
>  - The OS initializing the new virtual memory to zero
>  - Object::InitializeObject initializing to object null
>  - TypedData::New reinitializing to zero
> 
> Change-Id: I432944919ab68aecb2038bba245594bbbaed9093
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130928
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,aam@google.com,rmacnak@google.com

Change-Id: I92818954ddd715f295c1cbe413733236970a991e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133661
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-01-29 00:18:34 +00:00
Ryan Macnak 6fcee199af [vm] Initialize large typed arrays only once.
Previously large (>256k) typed arrays would be initialized 3 times:
 - The OS initializing the new virtual memory to zero
 - Object::InitializeObject initializing to object null
 - TypedData::New reinitializing to zero

Change-Id: I432944919ab68aecb2038bba245594bbbaed9093
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130928
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-28 21:22:20 +00:00
Ryan Macnak ea089033d7 [vm, gc] Use the compactor for the GC of last resort.
Change-Id: I858ff7b93321c8810d3ebe19e7cd18108f91764a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95963
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-01-27 22:26:17 +00:00
Ryan Macnak 155c0d1b92 Reapply "[vm, gc] Sweep non-executable large pages concurrently."
Wait for the concurrent sweeper to visit processing large pages before visiting the card tables during a scavenge.

Bug: https://github.com/flutter/flutter/issues/48360
Bug: b/147582727
Change-Id: Iaec22f05e22d9ded75017aa1d8463c1be64858aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131703
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-01-27 19:43:09 +00:00
Alexander Aprelev e2aadc7a07 Reland "[vm/fieldtable] Move current field values out of Field object into separate table."
This reverts commit c8f8c11b70 with the fix for https://github.com/flutter/flutter/issues/49008 in Patchset 2.

Change-Id: I85406b92a69ed950d0ba945f96997658be3cae64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132302
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-01-17 18:12:24 +00:00
Alexander Aprelev c8f8c11b70 Revert "[vm/fieldtable] Move current field values out of Field object into separate table."
This reverts commit 85e396a1de as it broke internal app running on android arm in release mode.

Change-Id: Iaff0cf3c1ef859e35b4eaeb3ac8243ce3c6737b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132168
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-01-17 00:24:20 +00:00
Ryan Macnak 67f3cf325d Revert "[vm, gc] Sweep non-executable large pages concurrently."
Race between sweeper and scavenger accessing card tables.

This reverts commit 4f1270655c.

Bug: b/147582727
Change-Id: I824f8ddbbd48bd69bda565b4ead0238b57482ef9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131422
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-01-13 20:26:06 +00:00
Ryan Macnak 4495c2b30a [vm, gc] Run weak processing in parallel for old-space GCs.
Allow updating weak handles, weak pointers, the object id ring and the remembered set to happen in parallel with work-stealing.

Change-Id: I70c15cde412e0ce8737c13b4b682f408596def7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131161
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-01-13 18:31:36 +00:00
Ryan Macnak 9c9c283c78 [vm, gc] Remove dead allocation stats code.
This should have been removed in 545b10389d.

Bug: https://github.com/dart-lang/sdk/issues/37678
Change-Id: Ie679e68b76e339843fcfe00e866be6478b9cc98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131201
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-01-13 17:21:16 +00:00
Ryan Macnak 4f1270655c [vm, gc] Sweep non-executable large pages concurrently.
In some workloads, the heap is mostly large pages.

Move large executable pages from the large list to the executable list. They do not require special treatment because they are large during sweeping because we never truncate an Instructions object. They still require being swept immediately because they are executable so that code protections can be flipped before resuming Dart execution.

Fix off-by-one errors in SnapshotGraph.objects and SnapshotClass.instances discovered as a result of the large page list changing from prepending to appending.

Bug: https://github.com/flutter/flutter/issues/48360
Change-Id: If6d9137fd36c9b18205493166d586b9a7cee4b1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130823
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-01-10 21:12:51 +00:00
Ryan Macnak 361f4abfe0 [vm, gc] Add missing check to begin concurrent marking during large page allocation.
Bug: https://github.com/flutter/flutter/issues/48360
Change-Id: Iaa869bc5c1d4f85481e3ff89d6af16eba893f756
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130737
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-01-09 01:02:48 +00:00
Ryan Macnak 5b8c4e8024 [vm, service] Speed up generation and transmission of heap snapshots.
- Remove server-side transmission bottleneck in WebSocket compression.
 - Remove client-side transmission bottleneck in response inflation.
 - Remove generation bottleneck and memory overhead of WeakTables by using a finger table.

On dart2js self compile, 1.5GB heap, 400MB heap snapshot
Time to generate and transmit:    46 -> 5s
Auxiliary memory for WeakTables: 537 -> 1.5MB

Change-Id: Ia58e2ffb942e5d29536e175d9caedd2bf835981a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130621
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-01-08 03:22:59 +00:00
Alexander Aprelev 85e396a1de [vm/fieldtable] Move current field values out of Field object into separate table.
This is to support sharing of Field objects between isolate group's isolates.

Each isolate will have it's own field table with static instances/values.
field_table is stored on isolate, copied over to thread for easier access.

This also removes the write barrier from static field assignments; the field table is a GC root.

Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I232a86f059ac4cacc3e9f54bcc31d1d0524f9496
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127582
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-01-06 18:58:11 +00:00
Ryan Macnak f6677c3862 [vm, service] Account for image pages in the capacity reported by heap snapshots.
The VM does not include image pages in its usual accounting of heap usage and capacity because they are immortal and don't contribute to marking or sweeping work. The heap snapshot does include objects on these pages, so it should include the pages in its notion of usage and capacity, otherwise the heap-snapshot can effectively claim it has more usage than capacity.

Fixes negative fragmentation reported by the heap snapshot page.

Change-Id: Ib9f3c395ee5a6e51ee9b4c9a834843851426910d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128565
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-01-02 21:26:59 +00:00
Alexander Aprelev 0cc27b5db0 Reland "[vm, linux] Try to attach names to all VirtualMemory allocations using memfd."
This reverts commit 4dee4bd204 as it now has the fix for precompiled flow in patchsets 3, 7.

Change-Id: Ib99763a91073df7698e8b597a67e11e557fc131e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128574
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-12-18 18:02:41 +00:00
Clement Skau 4dee4bd204 Revert "[vm, linux] Try to attach names to all VirtualMemory allocations using memfd."
This reverts commit f5e57f89d2.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> [vm, linux] Try to attach names to all VirtualMemory allocations using memfd.
> 
> For example,
> 
> $ cat /proc/<pid>/smaps
> ...
> 7fd2ad2e0000-7fd2ad2f0000 rw-s 00000000 00:05 15576579 /memfd:dart-zone (deleted)
> 7fd2b2b7f000-7fd2b2d7f000 rw-s 00000000 00:05 15695692 /memfd:dart-newspace (deleted)
> 7fd2b2f00000-7fd2b2f80000 r--s 00000000 00:05 15695687 /memfd:dart-codespace (deleted)
> 7fd2b2f80000-7fd2b3000000 r--s 00000000 00:05 15695685 /memfd:dart-oldspace (deleted)
> 7fd2b3163000-7fd2b3beb000 rw-s 00000000 00:05 15695684 /memfd:dart-profiler (deleted)
> 7fd2b3beb000-7fd2b3eb0000 rw-s 00000000 00:05 15695683 /memfd:dart-timeline (deleted)
> ...
> 
> Bug: b/144232910
> Change-Id: I9722247853b244daff63b7a631678d44e19c2d69
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128603
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=aam@google.com,rmacnak@google.com,asiva@google.com,chinmaygarde@google.com

Change-Id: I8a983d4650ca10e9c7396536603af21c974dcb78
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/144232910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128587
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-12-17 11:14:19 +00:00
Ryan Macnak f5e57f89d2 [vm, linux] Try to attach names to all VirtualMemory allocations using memfd.
For example,

$ cat /proc/<pid>/smaps
...
7fd2ad2e0000-7fd2ad2f0000 rw-s 00000000 00:05 15576579 /memfd:dart-zone (deleted)
7fd2b2b7f000-7fd2b2d7f000 rw-s 00000000 00:05 15695692 /memfd:dart-newspace (deleted)
7fd2b2f00000-7fd2b2f80000 r--s 00000000 00:05 15695687 /memfd:dart-codespace (deleted)
7fd2b2f80000-7fd2b3000000 r--s 00000000 00:05 15695685 /memfd:dart-oldspace (deleted)
7fd2b3163000-7fd2b3beb000 rw-s 00000000 00:05 15695684 /memfd:dart-profiler (deleted)
7fd2b3beb000-7fd2b3eb0000 rw-s 00000000 00:05 15695683 /memfd:dart-timeline (deleted)
...

Bug: b/144232910
Change-Id: I9722247853b244daff63b7a631678d44e19c2d69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128603
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-12-16 23:30:03 +00:00