Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_V8_PROFILER_H_ | 5 #ifndef V8_V8_PROFILER_H_ |
| 6 #define V8_V8_PROFILER_H_ | 6 #define V8_V8_PROFILER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "v8.h" // NOLINT(build/include) | 9 #include "v8.h" // NOLINT(build/include) |
| 10 | 10 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 int64_t* timestamp_us = NULL); | 515 int64_t* timestamp_us = NULL); |
| 516 | 516 |
| 517 /** | 517 /** |
| 518 * Stops tracking of heap objects population statistics, cleans up all | 518 * Stops tracking of heap objects population statistics, cleans up all |
| 519 * collected data. StartHeapObjectsTracking must be called again prior to | 519 * collected data. StartHeapObjectsTracking must be called again prior to |
| 520 * calling GetHeapStats next time. | 520 * calling GetHeapStats next time. |
| 521 */ | 521 */ |
| 522 void StopTrackingHeapObjects(); | 522 void StopTrackingHeapObjects(); |
| 523 | 523 |
| 524 /** | 524 /** |
| 525 * Starts gathering a sampling heap profile. A sampling heap profile is | |
| 526 * similar to tcmalloc's heap profiler and Go's mprof. It samples object | |
| 527 * allocations and builds an online 'sampling' heap profile. At any point in | |
| 528 * time, this profile is expected to be a representative sample of objects | |
| 529 * 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
| |
| 530 * trace at the time of allocation, which makes this really useful for memory | |
| 531 * leak detection. | |
| 532 * | |
| 533 * This mechanism is intended to be cheap enough that it can be used in | |
| 534 * production with minimal performance overhead. | |
| 535 * | |
| 536 * Allocations are sampled using a randomized Poisson process. On average, one | |
| 537 * allocation will be sampled every |sample_interval| bytes allocated. The | |
| 538 * |stack_depth| parameter controls the maximum number of stack frames to be | |
| 539 * captured on each allocation. | |
| 540 * | |
| 541 * NOTE: This is a proof-of-concept at this point. Right now we only sample | |
| 542 * newspace allocations. Support for paged space allocation (e.g. pre-tenured | |
| 543 * objects, large objects, code objects, etc.) and native allocations | |
| 544 * doesn't exist yet, but is anticipated in the future. | |
| 545 * | |
| 546 * Returns false if a sampling heap profiler is already running. | |
| 547 */ | |
| 548 bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024, | |
| 549 int stack_depth = 16); | |
| 550 | |
| 551 /** | |
| 552 * Stops the sampling heap profile and discards the current profile. | |
| 553 */ | |
| 554 void StopSamplingHeapProfiler(); | |
| 555 | |
| 556 /** | |
| 557 * Returns the set of currently live sampled allocations as a JSON string in | |
| 558 * the stream. | |
| 559 */ | |
| 560 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
| |
| 561 | |
| 562 /** | |
| 525 * Deletes all snapshots taken. All previously returned pointers to | 563 * Deletes all snapshots taken. All previously returned pointers to |
| 526 * snapshots and their contents become invalid after this call. | 564 * snapshots and their contents become invalid after this call. |
| 527 */ | 565 */ |
| 528 void DeleteAllHeapSnapshots(); | 566 void DeleteAllHeapSnapshots(); |
| 529 | 567 |
| 530 /** Binds a callback to embedder's class ID. */ | 568 /** Binds a callback to embedder's class ID. */ |
| 531 void SetWrapperClassInfoProvider( | 569 void SetWrapperClassInfoProvider( |
| 532 uint16_t class_id, | 570 uint16_t class_id, |
| 533 WrapperInfoCallback callback); | 571 WrapperInfoCallback callback); |
| 534 | 572 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 uint32_t index; // Index of the time interval that was changed. | 677 uint32_t index; // Index of the time interval that was changed. |
| 640 uint32_t count; // New value of count field for the interval with this index. | 678 uint32_t count; // New value of count field for the interval with this index. |
| 641 uint32_t size; // New value of size field for the interval with this index. | 679 uint32_t size; // New value of size field for the interval with this index. |
| 642 }; | 680 }; |
| 643 | 681 |
| 644 | 682 |
| 645 } // namespace v8 | 683 } // namespace v8 |
| 646 | 684 |
| 647 | 685 |
| 648 #endif // V8_V8_PROFILER_H_ | 686 #endif // V8_V8_PROFILER_H_ |
| OLD | NEW |