Skip to content

Commit 5966b8c

Browse files
FlarnaMylesBorins
authored andcommitted
deps: v8: cherry-pick fixes for v8:7535
These changes avoid a busy wait loop in V8 CPU Profiler thread for windows (except for short intervals). It would be good if this is also backported to Node.js v9 and LTS releases as this busy loop effectively disallows the use of cpu-profiler in windows production setups. Original commit message 15c0c3a8ba: ``` [profiler] use Sleep() on windows for long profile intervals. See nodejs/diagnostics#170 R=franzih@chromium.org Change-Id: Iecc3bb27707b0d2afbb23fd9823d5cd4d725be6e Reviewed-on: https://chromium-review.googlesource.com/931102 Reviewed-by: Franziska Hinkelmann <franzih@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#51466} ``` Original commit message 43e2fb1c3d: ``` [profiler] fix sleeping on windows for long intervals. R=franzih@chromium.org Change-Id: I5717db794fc797e7c3b0b8f122ddb6dc0702a99e Reviewed-on: https://chromium-review.googlesource.com/941126 Reviewed-by: Franziska Hinkelmann <franzih@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#51755} ``` PR-URL: #19333 Refs: nodejs/diagnostics#170 Refs: #19200 Refs: v8/v8@15c0c3a Refs: v8/v8@43e2fb1 Reviewed-By: Myles Borins <myles.borins@gmail.com>
1 parent 03c321a commit 5966b8c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Reset this number to 0 on major V8 upgrades.
2929
# Increment by one for each non-official patch applied to deps/v8.
30-
'v8_embedder_string': '-node.21',
30+
'v8_embedder_string': '-node.22',
3131

3232
# Enable disassembler for `--print-code` v8 options
3333
'v8_enable_disassembler': 1,

deps/v8/src/profiler/cpu-profiler.cc

+9-6
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,16 @@ void ProfilerEventsProcessor::Run() {
162162

163163
if (nextSampleTime > now) {
164164
#if V8_OS_WIN
165-
// Do not use Sleep on Windows as it is very imprecise.
166-
// Could be up to 16ms jitter, which is unacceptable for the purpose.
167-
while (base::TimeTicks::HighResolutionNow() < nextSampleTime) {
168-
}
169-
#else
170-
base::OS::Sleep(nextSampleTime - now);
165+
if (nextSampleTime - now < base::TimeDelta::FromMilliseconds(100)) {
166+
// Do not use Sleep on Windows as it is very imprecise, with up to 16ms
167+
// jitter, which is unacceptable for short profile intervals.
168+
while (base::TimeTicks::HighResolutionNow() < nextSampleTime) {
169+
}
170+
} else // NOLINT
171171
#endif
172+
{
173+
base::OS::Sleep(nextSampleTime - now);
174+
}
172175
}
173176

174177
// Schedule next sample. sampler_ is NULL in tests.

0 commit comments

Comments
 (0)