pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/Rohan5commit/node/commit/8385efc01343a835e3a0efe05611f44272cbb413

crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-7a1ad343bd40328c.css" /> deps: V8: cherry-pick 0f024d4e66e0 · Rohan5commit/node@8385efc · GitHub
Skip to content

Commit 8385efc

Browse files
IlyasShabibengl
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: nodejs#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 7466249 commit 8385efc

5 files changed

Lines changed: 86 additions & 2 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

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

4545
##### V8 defaults for Node.js #####
4646

deps/v8/AUTHORS

Lines 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>

deps/v8/include/v8-profiler.h

Lines 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
/**

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

Lines 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
}

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

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy