Repository navigation
Conversation
Original commit message:
[profiler] Move SampleContextExtractor to a CpuProfiler setter
The SampleContextExtractor was passed per profile in
CpuProfilingOptions, but it is bound to the events processor that all
profiles of a CpuProfiler share, taken from the profile that starts the
processor. A profile started while another was active therefore
silently had its extractor ignored, a profile started without an
extractor still received the other profile's sample contexts, and the
extractor kept being invoked after the profile that installed it had
stopped. None of this matched the documented per-profile contract of
CpuProfile::GetSampleContext.
Make the API reflect the actual binding instead: remove the extractor
from CpuProfilingOptions and install it with
CpuProfiler::SetSampleContextExtractor instead which, like
SetSamplingInterval and SetUsePreciseSampling, must be called while no
profiles are being recorded. Every profile recorded by the CpuProfiler
receives its sample contexts, and embedders wanting different extractors
can use a separate CpuProfiler for each.
This changes the CpuProfilingOptions constructor back to its signature
before the extractor was added.
Bug: 572878256
Change-Id: I73b0e7c3c2744c7fbaf72b95074a4ae0e8d0f855
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8579337
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Olivier Flückiger <olivf@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#111365}
Refs: v8/v8@b3a92f0
Assisted-by: Claude
Signed-off-by: Attila Szegedi <attila.szegedi@datadoghq.com>
|
Review requested:
|
|
Hi! This pull request changes In general we recommend waiting for a V8 patch to be included in the next V8 major version update instead of fast-tracking it, since individual backports add audit cost and can delay the major update. A patch may be backported to
If the patch has demonstrated real-world urgency and impact that justifies landing it before the next V8 major version update, it's recommended to backport it to the release staging branches like Please explain in the pull request description which of these criteria applies. Otherwise, consider closing this pull request and waiting for the next V8 update instead of fast-tracking a backport. See Backporting patches to |
Cherry-picks v8/v8@b3a92f0 ("[profiler] Move SampleContextExtractor to a CpuProfiler setter") from V8 upstream.
V8 15.8, which
maincurrently uses, already contains the earlier commit (v8/v8@155cd72) that addedSampleContextExtractoras a per-profile option inCpuProfilingOptions. However, the extractor is actually bound to the events processor shared by all profiles of aCpuProfiler, so the per-profile API did not behave as documented. The upstream follow-up, which first ships in V8 15.9, removes the extractor fromCpuProfilingOptionsand addsCpuProfiler::SetSampleContextExtractorinstead.Floating this patch means Node.js never ships the per-profile shape of this API, including in v27 alphas that pick up V8 15.8. It becomes redundant once
mainupdates to V8 15.9 or later. This would unblock progress on #63163, which is the original source of the V8 code for both commits, that I got upstreamed.Notes:
deps/v8diff is identical to the upstream commit.v8_embedder_stringis bumped to-node.5.CpuProfilingOptionsconstructor to its pre-15.8 signature, which changes V8's public API/ABI. Nothing in Node.js core usesSampleContextExtractor.