Skip to content

Commit

Permalink
[vm] Avoid data race during Dart_IsolateGroupHeapNewUsedMetric.
Browse files Browse the repository at this point in the history
Precise new-space usage requires looking at all the TLAB pointers and normally only occurs under a GC safepoint. For external queries coarsen the answer to capacity.

TEST=g3
Bug: b/324221135
Change-Id: I0e83bbcddba21ddf539fb2afdedf2959cef2c078
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352682
Reviewed-by: Siva Annamalai <[email protected]>
Commit-Queue: Ryan Macnak <[email protected]>
  • Loading branch information
rmacnak-google authored and Commit Queue committed Feb 14, 2024
1 parent 974dfa3 commit a407280
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/vm/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ int64_t MetricHeapOldExternal::Value() const {

int64_t MetricHeapNewUsed::Value() const {
ASSERT(isolate_group() == IsolateGroup::Current());
return isolate_group()->heap()->UsedInWords(Heap::kNew) * kWordSize;
// UsedInWords requires a safepoint to access all the TLAB pointers without a
// data race, so coarsen this metric to capacity. Preferable to locking during
// new-space allocation.
return isolate_group()->heap()->CapacityInWords(Heap::kNew) * kWordSize;
}

int64_t MetricHeapNewCapacity::Value() const {
Expand Down

0 comments on commit a407280

Please sign in to comment.