[vm] Do not interrupt mutator when SampleBlock is complete

This code was added when samples streaming was implemented and should
not be necessary. Let background thread drain samples instead.

This significantly reduces the overhead of activating profiler when
using NativeRuntime.streamTimelineTo from 2-3x to ~10% in AOT mode
and around ~20-25% in JIT.

TEST=ci

Change-Id: I4c6026f832d6a952b24323632b4126df6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464183
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
This commit is contained in:
Slava Egorov
2025-11-24 13:29:52 -08:00
committed by Commit Queue
parent 2509b87755
commit badeb15e5d
2 changed files with 1 additions and 13 deletions
+1 -6
View File
@@ -909,12 +909,7 @@ Sample* SampleBlockBuffer::ReserveSampleImpl(Isolate* isolate,
if (block != nullptr) {
block->MarkCompleted();
if (!Isolate::IsSystemIsolate(isolate)) {
Thread* mutator = isolate->IGNORE_RACE(mutator_thread)();
// The mutator thread might be NULL if we sample in the middle of
// Thread::Enter/ExitIsolate.
if ((mutator != nullptr) && isolate->TrySetHasCompletedBlocks()) {
mutator->ScheduleInterrupts(Thread::kVMInterrupt);
}
isolate->TrySetHasCompletedBlocks();
}
}
return next->ReserveSample();
-7
View File
@@ -857,13 +857,6 @@ ErrorPtr Thread::HandleInterrupts(uword interrupt_bits) {
}
heap()->CheckFinalizeMarking(this);
#if !defined(PRODUCT)
// TODO(dartbug.com/60508): Allow profiling of isolate-group-shared code.
if (isolate() != nullptr && isolate()->TakeHasCompletedBlocks()) {
Profiler::ProcessCompletedBlocks(isolate());
}
#endif // !defined(PRODUCT)
#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
HeapProfileSampler& sampler = heap_sampler();
if (sampler.ShouldSetThreadSamplingInterval()) {