Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: include/v8-profiler.h

Issue 1555553002: [profiler] Implement POC Sampling Heap Profiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup samples when sampling heap profiler is stopped Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8-profiler.h
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index e432600290c6bb3e6749e7836b916eb5e0315e17..34f6447e60311bae6cb3d7deeca237f18030d36a 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -522,6 +522,44 @@ class V8_EXPORT HeapProfiler {
void StopTrackingHeapObjects();
/**
+ * Starts gathering a sampling heap profile. A sampling heap profile is
+ * similar to tcmalloc's heap profiler and Go's mprof. It samples object
+ * allocations and builds an online 'sampling' heap profile. At any point in
+ * time, this profile is expected to be a representative sample of objects
+ * currently live in the system. Each sampled allocation includes the stack
Yang 2016/01/07 06:14:10 Not questioning the effectiveness, just curious: c
ofrobots 2016/01/07 06:49:30 We do observe death as well. We keep a weak refere
jochen (gone - plz use gerrit) 2016/01/07 10:29:34 note that it's not possible to create weak referen
+ * trace at the time of allocation, which makes this really useful for memory
+ * leak detection.
+ *
+ * This mechanism is intended to be cheap enough that it can be used in
+ * production with minimal performance overhead.
+ *
+ * Allocations are sampled using a randomized Poisson process. On average, one
+ * allocation will be sampled every |sample_interval| bytes allocated. The
+ * |stack_depth| parameter controls the maximum number of stack frames to be
+ * captured on each allocation.
+ *
+ * NOTE: This is a proof-of-concept at this point. Right now we only sample
+ * newspace allocations. Support for paged space allocation (e.g. pre-tenured
+ * objects, large objects, code objects, etc.) and native allocations
+ * doesn't exist yet, but is anticipated in the future.
+ *
+ * Returns false if a sampling heap profiler is already running.
+ */
+ bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
+ int stack_depth = 16);
+
+ /**
+ * Stops the sampling heap profile and discards the current profile.
+ */
+ void StopSamplingHeapProfiler();
+
+ /**
+ * Returns the set of currently live sampled allocations as a JSON string in
+ * the stream.
+ */
+ void GetHeapSample(OutputStream* stream);
Yang 2016/01/07 06:14:10 I wonder whether it makes better sense to use the
ofrobots 2016/01/07 06:49:30 One of the difference is that heap-snapshot gives
+
+ /**
* Deletes all snapshots taken. All previously returned pointers to
* snapshots and their contents become invalid after this call.
*/
« no previous file with comments | « BUILD.gn ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698