Return timestamp of the last recorded interval to the caller of HeapProfiler::GetHeapStats
Before this patch the embedder could assign timestamp to the last interval after calling GetHeapStats. This would be slightly different from the timstamps assigned by v8 internally and written into heap snapshot. This patch allow to avoid this small discrepancy by returning timestamp along with last heap stats update. BUG=chromium:467222 LOG=Y Review URL: https://codereview.chromium.org/1037803002 Cr-Commit-Position: refs/heads/master@{#27466}
This commit is contained in:
parent
4518e92706
commit
f13d04d28c
@ -471,17 +471,19 @@ class V8_EXPORT HeapProfiler {
|
||||
* reports updates for all previous time intervals via the OutputStream
|
||||
* object. Updates on each time interval are provided as a stream of the
|
||||
* HeapStatsUpdate structure instances.
|
||||
* The return value of the function is the last seen heap object Id.
|
||||
* If |timestamp_us| is supplied, timestamp of the new entry will be written
|
||||
* into it. The return value of the function is the last seen heap object Id.
|
||||
*
|
||||
* StartTrackingHeapObjects must be called before the first call to this
|
||||
* method.
|
||||
*/
|
||||
SnapshotObjectId GetHeapStats(OutputStream* stream);
|
||||
SnapshotObjectId GetHeapStats(OutputStream* stream,
|
||||
int64_t* timestamp_us = NULL);
|
||||
|
||||
/**
|
||||
* Stops tracking of heap objects population statistics, cleans up all
|
||||
* collected data. StartHeapObjectsTracking must be called again prior to
|
||||
* calling PushHeapObjectsStats next time.
|
||||
* calling GetHeapStats next time.
|
||||
*/
|
||||
void StopTrackingHeapObjects();
|
||||
|
||||
|
@ -7789,8 +7789,10 @@ void HeapProfiler::StopTrackingHeapObjects() {
|
||||
}
|
||||
|
||||
|
||||
SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) {
|
||||
return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream);
|
||||
SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream,
|
||||
int64_t* timestamp_us) {
|
||||
i::HeapProfiler* heap_profiler = reinterpret_cast<i::HeapProfiler*>(this);
|
||||
return heap_profiler->PushHeapObjectsStats(stream, timestamp_us);
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,8 +91,9 @@ void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) {
|
||||
}
|
||||
|
||||
|
||||
SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
|
||||
return ids_->PushHeapObjectsStats(stream);
|
||||
SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream,
|
||||
int64_t* timestamp_us) {
|
||||
return ids_->PushHeapObjectsStats(stream, timestamp_us);
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,8 @@ class HeapProfiler {
|
||||
HeapObjectsMap* heap_object_map() const { return ids_.get(); }
|
||||
StringsStorage* names() const { return names_.get(); }
|
||||
|
||||
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
|
||||
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream,
|
||||
int64_t* timestamp_us);
|
||||
int GetSnapshotsCount();
|
||||
HeapSnapshot* GetSnapshot(int index);
|
||||
SnapshotObjectId GetSnapshotObjectId(Handle<Object> obj);
|
||||
|
@ -611,7 +611,8 @@ int HeapObjectsMap::FindUntrackedObjects() {
|
||||
}
|
||||
|
||||
|
||||
SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) {
|
||||
SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream,
|
||||
int64_t* timestamp_us) {
|
||||
UpdateHeapObjectsMap();
|
||||
time_intervals_.Add(TimeInterval(next_id_));
|
||||
int prefered_chunk_size = stream->GetChunkSize();
|
||||
@ -653,6 +654,10 @@ SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) {
|
||||
if (result == OutputStream::kAbort) return last_assigned_id();
|
||||
}
|
||||
stream->EndOfStream();
|
||||
if (timestamp_us) {
|
||||
*timestamp_us = (time_intervals_.last().timestamp -
|
||||
time_intervals_[0].timestamp).InMicroseconds();
|
||||
}
|
||||
return last_assigned_id();
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,8 @@ class HeapObjectsMap {
|
||||
}
|
||||
|
||||
void StopHeapObjectsTracking();
|
||||
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
|
||||
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream,
|
||||
int64_t* timestamp_us);
|
||||
const List<TimeInterval>& samples() const { return time_intervals_; }
|
||||
size_t GetUsedMemorySize() const;
|
||||
|
||||
|
@ -1044,9 +1044,12 @@ static TestStatsStream GetHeapStatsUpdate(
|
||||
v8::HeapProfiler* heap_profiler,
|
||||
v8::SnapshotObjectId* object_id = NULL) {
|
||||
TestStatsStream stream;
|
||||
v8::SnapshotObjectId last_seen_id = heap_profiler->GetHeapStats(&stream);
|
||||
int64_t timestamp = -1;
|
||||
v8::SnapshotObjectId last_seen_id =
|
||||
heap_profiler->GetHeapStats(&stream, ×tamp);
|
||||
if (object_id)
|
||||
*object_id = last_seen_id;
|
||||
CHECK_NE(-1, timestamp);
|
||||
CHECK_EQ(1, stream.eos_signaled());
|
||||
return stream;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user