Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dae2219

Browse filesBrowse files
IlyasShabiRafaelGSS
authored andcommitted
deps: V8: cherry-pick 0f024d4e66e0
Original commit message: [heap profiler] Add is_live field to AllocationProfile::Sample When using kSamplingIncludeObjectsCollectedByMajorGC/MinorGC flag, samples for collected objects are retained but callers had no way to distinguish live from dead objects. Add is_live to expose this information. Change-Id: I2e930644348ff942caa4b192a127c5baa05bbfef Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7603535 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#105698} Refs: v8/v8@0f024d4 Signed-off-by: ishabi <ilyasshabi94@gmail.com> PR-URL: #62408 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent f6ce381 commit dae2219
Copy full SHA for dae2219

5 files changed

+86-2Lines changed: 86 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.18',
41+
'v8_embedder_string': '-node.19',
4242

4343
##### V8 defaults for Node.js #####
4444

Collapse file

‎deps/v8/AUTHORS‎

Copy file name to clipboardExpand all lines: deps/v8/AUTHORS
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Huáng Jùnliàng <jlhwung@gmail.com>
155155
HyeockJin Kim <kherootz@gmail.com>
156156
Iain Ireland <iireland@mozilla.com>
157157
Ilya Gavrilin <ilya.gavrilin@syntacore.com>
158+
Ilyas Shabi <ilyasshabi94@gmail.com>
158159
Ingvar Stepanyan <me@rreverser.com>
159160
Ioseb Dzmanashvili <ioseb.dzmanashvili@gmail.com>
160161
Isiah Meadows <impinball@gmail.com>
Collapse file

‎deps/v8/include/v8-profiler.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8-profiler.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,12 @@ class V8_EXPORT AllocationProfile {
830830
* what samples were added or removed between two snapshots.
831831
*/
832832
uint64_t sample_id;
833+
834+
/**
835+
* Indicates whether the sampled allocation is still live or has already
836+
* been collected by GC.
837+
*/
838+
bool is_live;
833839
};
834840

835841
/**
Collapse file

‎deps/v8/src/profiler/sampling-heap-profiler.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/profiler/sampling-heap-profiler.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ SamplingHeapProfiler::BuildSamples() const {
312312
samples.reserve(samples_.size());
313313
for (const auto& it : samples_) {
314314
const Sample* sample = it.second.get();
315+
const bool is_live = !sample->global.IsEmpty();
315316
samples.emplace_back(v8::AllocationProfile::Sample{
316317
sample->owner->id_, sample->size, ScaleSample(sample->size, 1).count,
317-
sample->sample_id});
318+
sample->sample_id, is_live});
318319
}
319320
return samples;
320321
}
Collapse file

‎deps/v8/test/cctest/test-heap-profiler.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-heap-profiler.cc
+76Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,6 +4442,82 @@ TEST(SamplingHeapProfilerLargeInterval) {
44424442
heap_profiler->StopSamplingHeapProfiler();
44434443
}
44444444

4445+
TEST(SamplingHeapProfilerSampleWithoutGCFlags) {
4446+
v8::HandleScope scope(CcTest::isolate());
4447+
LocalContext env;
4448+
v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler();
4449+
4450+
// Suppress randomness to avoid flakiness in tests.
4451+
i::v8_flags.sampling_heap_profiler_suppress_randomness = true;
4452+
4453+
heap_profiler->StartSamplingHeapProfiler(1024);
4454+
4455+
// Allocate objects that will be retained
4456+
CompileRun(
4457+
"var retained = [];\n"
4458+
"for (var i = 0; i < 500; i++) retained.push(new Array(10));\n");
4459+
4460+
CompileRun("for (var i = 0; i < 500; i++) new Array(10);\n");
4461+
4462+
std::unique_ptr<v8::AllocationProfile> profile(
4463+
heap_profiler->GetAllocationProfile());
4464+
CHECK(profile);
4465+
4466+
const auto& samples = profile->GetSamples();
4467+
CHECK(!samples.empty());
4468+
4469+
for (const auto& sample : samples) {
4470+
CHECK(sample.is_live);
4471+
}
4472+
4473+
heap_profiler->StopSamplingHeapProfiler();
4474+
}
4475+
4476+
TEST(SamplingHeapProfilerSampleIsLive) {
4477+
v8::HandleScope scope(CcTest::isolate());
4478+
LocalContext env;
4479+
v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler();
4480+
4481+
// Suppress randomness to avoid flakiness in tests.
4482+
i::v8_flags.sampling_heap_profiler_suppress_randomness = true;
4483+
4484+
heap_profiler->StartSamplingHeapProfiler(
4485+
64, 16,
4486+
static_cast<v8::HeapProfiler::SamplingFlags>(
4487+
v8::HeapProfiler::kSamplingForceGC |
4488+
v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMajorGC));
4489+
4490+
// Allocate objects that will be retained
4491+
CompileRun(
4492+
"var retained = [];\n"
4493+
"for (var i = 0; i < 500; i++) retained.push(new Array(10));\n");
4494+
4495+
CompileRun("for (var i = 0; i < 500; i++) new Array(10);\n");
4496+
4497+
std::unique_ptr<v8::AllocationProfile> profile(
4498+
heap_profiler->GetAllocationProfile());
4499+
CHECK(profile);
4500+
4501+
const auto& samples = profile->GetSamples();
4502+
CHECK(!samples.empty());
4503+
4504+
int live_samples = 0;
4505+
int dead_samples = 0;
4506+
for (const auto& sample : samples) {
4507+
if (sample.is_live) {
4508+
++live_samples;
4509+
} else {
4510+
++dead_samples;
4511+
}
4512+
}
4513+
4514+
// We expect both retained and collected allocations in this profile.
4515+
CHECK_GT(live_samples, 0);
4516+
CHECK_GT(dead_samples, 0);
4517+
4518+
heap_profiler->StopSamplingHeapProfiler();
4519+
}
4520+
44454521
TEST(HeapSnapshotPrototypeNotJSReceiver) {
44464522
LocalContext env;
44474523
v8::HandleScope scope(env.isolate());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.