Commit 95b9cff1 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Use CurrentTimeTicks instead of CurrentTimeTicksInMilliseconds in platform/.

TimeTicks are less confusing than double (which can be variously seconds
and milliseconds).

Change-Id: I70badbc63c8f8a1c8226f50b5ccb7d70d8209314
Reviewed-on: https://chromium-review.googlesource.com/1099370Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567287}
parent b7224e31
......@@ -196,9 +196,11 @@ bool ScriptWrappableMarkingVisitor::AdvanceTracing(
CHECK(!ThreadState::Current()->IsWrapperTracingForbidden());
CHECK(tracing_in_progress_);
base::AutoReset<bool>(&advancing_tracing_, true);
TimeTicks deadline =
TimeTicks() + TimeDelta::FromMillisecondsD(deadline_in_ms);
while (actions.force_completion ==
v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION ||
WTF::CurrentTimeTicksInMilliseconds() < deadline_in_ms) {
WTF::CurrentTimeTicks() < deadline) {
if (marking_deque_.IsEmpty()) {
return false;
}
......
......@@ -105,11 +105,16 @@ double ThreadHeapStatsCollector::estimated_marking_time_in_seconds() const {
: kInitialMarkingTimeInSeconds;
}
TimeDelta ThreadHeapStatsCollector::estimated_marking_time() const {
return TimeDelta::FromSecondsD(estimated_marking_time_in_seconds());
}
double ThreadHeapStatsCollector::Event::marking_time_in_ms() const {
return scope_data[kIncrementalMarkingStartMarking] +
scope_data[kIncrementalMarkingStep] +
scope_data[kIncrementalMarkingFinalizeMarking] +
scope_data[kAtomicPhaseMarking];
return (scope_data[kIncrementalMarkingStartMarking] +
scope_data[kIncrementalMarkingStep] +
scope_data[kIncrementalMarkingFinalizeMarking] +
scope_data[kAtomicPhaseMarking])
.InMillisecondsF();
}
double ThreadHeapStatsCollector::Event::marking_time_in_bytes_per_second()
......@@ -118,8 +123,9 @@ double ThreadHeapStatsCollector::Event::marking_time_in_bytes_per_second()
}
double ThreadHeapStatsCollector::Event::sweeping_time_in_ms() const {
return scope_data[kCompleteSweep] + scope_data[kEagerSweep] +
scope_data[kLazySweepInIdle] + scope_data[kLazySweepOnAllocation];
return (scope_data[kCompleteSweep] + scope_data[kEagerSweep] +
scope_data[kLazySweepInIdle] + scope_data[kLazySweepOnAllocation])
.InMillisecondsF();
}
size_t ThreadHeapStatsCollector::allocated_bytes_since_prev_gc() const {
......
......@@ -114,16 +114,13 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
public:
template <typename... Args>
inline InternalScope(ThreadHeapStatsCollector* tracer, Id id, Args... args)
: tracer_(tracer),
start_time_(WTF::CurrentTimeTicksInMilliseconds()),
id_(id) {
: tracer_(tracer), start_time_(WTF::CurrentTimeTicks()), id_(id) {
StartTrace(args...);
}
inline ~InternalScope() {
TRACE_EVENT_END0(TraceCategory(), ToString(id_));
tracer_->IncreaseScopeTime(
id_, WTF::CurrentTimeTicksInMilliseconds() - start_time_);
tracer_->IncreaseScopeTime(id_, WTF::CurrentTimeTicks() - start_time_);
}
private:
......@@ -146,7 +143,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
}
ThreadHeapStatsCollector* const tracer_;
const double start_time_;
const TimeTicks start_time_;
const Id id_;
};
......@@ -166,7 +163,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
size_t marked_bytes = 0;
size_t compaction_freed_bytes = 0;
size_t compaction_freed_pages = 0;
double scope_data[kNumScopeIds] = {0};
TimeDelta scope_data[kNumScopeIds];
BlinkGC::GCReason reason;
size_t object_size_in_bytes_before_sweeping = 0;
size_t allocated_space_in_bytes_before_sweeping = 0;
......@@ -186,7 +183,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
// is finished at this point.
void NotifySweepingCompleted();
void IncreaseScopeTime(Id id, double time) {
void IncreaseScopeTime(Id id, TimeDelta time) {
DCHECK(is_started_);
current_.scope_data[id] += time;
}
......@@ -211,6 +208,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
// the previous cycle assuming that the collection rate of the current cycle
// is similar to the rate of the last GC.
double estimated_marking_time_in_seconds() const;
TimeDelta estimated_marking_time() const;
size_t allocated_bytes_since_prev_gc() const;
......
......@@ -16,7 +16,7 @@ TEST(ThreadHeapStatsCollectorTest, InitialEmpty) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
for (int i = 0; i < ThreadHeapStatsCollector::kNumScopeIds; i++) {
EXPECT_DOUBLE_EQ(0.0, stats_collector.current().scope_data[i]);
EXPECT_EQ(TimeDelta(), stats_collector.current().scope_data[i]);
}
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
......@@ -26,10 +26,11 @@ TEST(ThreadHeapStatsCollectorTest, IncreaseScopeTime) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, 1.0);
EXPECT_DOUBLE_EQ(
1.0, stats_collector.current()
.scope_data[ThreadHeapStatsCollector::kIncrementalMarkingStep]);
ThreadHeapStatsCollector::kIncrementalMarkingStep,
TimeDelta::FromMilliseconds(1));
EXPECT_EQ(TimeDelta::FromMilliseconds(1),
stats_collector.current()
.scope_data[ThreadHeapStatsCollector::kIncrementalMarkingStep]);
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
}
......@@ -38,24 +39,26 @@ TEST(ThreadHeapStatsCollectorTest, StopMovesCurrentToPrevious) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, 1.0);
ThreadHeapStatsCollector::kIncrementalMarkingStep,
TimeDelta::FromMilliseconds(1));
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(
1.0, stats_collector.previous()
.scope_data[ThreadHeapStatsCollector::kIncrementalMarkingStep]);
EXPECT_EQ(TimeDelta::FromMilliseconds(1),
stats_collector.previous()
.scope_data[ThreadHeapStatsCollector::kIncrementalMarkingStep]);
}
TEST(ThreadHeapStatsCollectorTest, StopResetsCurrent) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, 1.0);
ThreadHeapStatsCollector::kIncrementalMarkingStep,
TimeDelta::FromMilliseconds(1));
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(
0.0, stats_collector.current()
.scope_data[ThreadHeapStatsCollector::kIncrementalMarkingStep]);
EXPECT_EQ(TimeDelta(),
stats_collector.current()
.scope_data[ThreadHeapStatsCollector::kIncrementalMarkingStep]);
}
TEST(ThreadHeapStatsCollectorTest, StartStop) {
......@@ -143,7 +146,7 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime1) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPhaseMarking, 1000.0);
ThreadHeapStatsCollector::kAtomicPhaseMarking, TimeDelta::FromSeconds(1));
stats_collector.NotifyMarkingCompleted();
stats_collector.IncreaseMarkedObjectSize(1024);
stats_collector.NotifySweepingCompleted();
......@@ -157,7 +160,7 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime2) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPhaseMarking, 1000.0);
ThreadHeapStatsCollector::kAtomicPhaseMarking, TimeDelta::FromSeconds(1));
stats_collector.NotifyMarkingCompleted();
stats_collector.IncreaseMarkedObjectSize(1024);
stats_collector.NotifySweepingCompleted();
......@@ -209,14 +212,18 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimeInMsFromIncrementalGC) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStartMarking, 7.0);
ThreadHeapStatsCollector::kIncrementalMarkingStartMarking,
TimeDelta::FromMilliseconds(7));
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, 2.0);
ThreadHeapStatsCollector::kIncrementalMarkingStep,
TimeDelta::FromMilliseconds(2));
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingFinalizeMarking, 1.0);
ThreadHeapStatsCollector::kIncrementalMarkingFinalizeMarking,
TimeDelta::FromMilliseconds(1));
// Ignore the full finalization.
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingFinalize, 3.0);
ThreadHeapStatsCollector::kIncrementalMarkingFinalize,
TimeDelta::FromMilliseconds(3));
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(10.0, stats_collector.previous().marking_time_in_ms());
......@@ -226,7 +233,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimeInMsFromFullGC) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPhaseMarking, 11.0);
ThreadHeapStatsCollector::kAtomicPhaseMarking,
TimeDelta::FromMilliseconds(11));
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(11.0, stats_collector.previous().marking_time_in_ms());
......@@ -237,7 +245,7 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimePerByteInS) {
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseMarkedObjectSize(1000);
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPhaseMarking, 1000.0);
ThreadHeapStatsCollector::kAtomicPhaseMarking, TimeDelta::FromSeconds(1));
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(
......@@ -248,15 +256,16 @@ TEST(ThreadHeapStatsCollectorTest, EventSweepingTimeInMs) {
ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::kTesting);
stats_collector.IncreaseScopeTime(ThreadHeapStatsCollector::kLazySweepInIdle,
1.0);
TimeDelta::FromMilliseconds(1));
stats_collector.IncreaseScopeTime(ThreadHeapStatsCollector::kLazySweepInIdle,
2.0);
TimeDelta::FromMilliseconds(2));
stats_collector.IncreaseScopeTime(ThreadHeapStatsCollector::kLazySweepInIdle,
3.0);
TimeDelta::FromMilliseconds(3));
stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kLazySweepOnAllocation, 4.0);
ThreadHeapStatsCollector::kLazySweepOnAllocation,
TimeDelta::FromMilliseconds(4));
stats_collector.IncreaseScopeTime(ThreadHeapStatsCollector::kCompleteSweep,
5.0);
TimeDelta::FromMilliseconds(5));
stats_collector.NotifyMarkingCompleted();
stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(15.0, stats_collector.previous().sweeping_time_in_ms());
......
......@@ -667,10 +667,9 @@ void ThreadState::PerformIdleGC(TimeTicks deadline) {
return;
}
TimeDelta estimated_marking_time = TimeDelta::FromSecondsD(
heap_->stats_collector()->estimated_marking_time_in_seconds());
TimeDelta idle_delta = deadline - CurrentTimeTicks();
if (idle_delta <= estimated_marking_time &&
TimeDelta estimated_marking_time =
heap_->stats_collector()->estimated_marking_time();
if ((deadline - CurrentTimeTicks()) <= estimated_marking_time &&
!Platform::Current()
->CurrentThread()
->Scheduler()
......@@ -1113,17 +1112,20 @@ void UpdateHistograms(const ThreadHeapStatsCollector::Event& event) {
DEFINE_STATIC_LOCAL(CustomCountHistogram, marking_time_histogram,
("BlinkGC.CollectGarbage", 0, 10 * 1000, 50));
marking_time_histogram.Count(
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseMarking]);
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseMarking]
.InMilliseconds());
DEFINE_STATIC_LOCAL(CustomCountHistogram, atomic_phase_marking_histogram,
("BlinkGC.AtomicPhaseMarking", 0, 10 * 1000, 50));
atomic_phase_marking_histogram.Count(
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseMarking]);
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseMarking]
.InMilliseconds());
DEFINE_STATIC_LOCAL(CustomCountHistogram, complete_sweep_histogram,
("BlinkGC.CompleteSweep", 1, 10 * 1000, 50));
complete_sweep_histogram.Count(
event.scope_data[ThreadHeapStatsCollector::kCompleteSweep]);
event.scope_data[ThreadHeapStatsCollector::kCompleteSweep]
.InMilliseconds());
DEFINE_STATIC_LOCAL(CustomCountHistogram, time_for_sweep_histogram,
("BlinkGC.TimeForSweepingAllObjects", 1, 10 * 1000, 50));
......@@ -1133,12 +1135,14 @@ void UpdateHistograms(const ThreadHeapStatsCollector::Event& event) {
CustomCountHistogram, pre_finalizers_histogram,
("BlinkGC.TimeForInvokingPreFinalizers", 1, 10 * 1000, 50));
pre_finalizers_histogram.Count(
event.scope_data[ThreadHeapStatsCollector::kInvokePreFinalizers]);
event.scope_data[ThreadHeapStatsCollector::kInvokePreFinalizers]
.InMilliseconds());
DEFINE_STATIC_LOCAL(CustomCountHistogram, time_for_heap_compaction_histogram,
("BlinkGC.TimeForHeapCompaction", 1, 10 * 1000, 50));
time_for_heap_compaction_histogram.Count(
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseCompaction]);
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseCompaction]
.InMilliseconds());
DEFINE_STATIC_LOCAL(
CustomCountHistogram, object_size_freed_by_heap_compaction,
......@@ -1150,7 +1154,8 @@ void UpdateHistograms(const ThreadHeapStatsCollector::Event& event) {
CustomCountHistogram, weak_processing_time_histogram,
("BlinkGC.TimeForGlobalWeakProcessing", 1, 10 * 1000, 50));
weak_processing_time_histogram.Count(
event.scope_data[ThreadHeapStatsCollector::kMarkWeakProcessing]);
event.scope_data[ThreadHeapStatsCollector::kMarkWeakProcessing]
.InMilliseconds());
DEFINE_STATIC_LOCAL(CustomCountHistogram, object_size_before_gc_histogram,
("BlinkGC.ObjectSizeBeforeGC", 1, 4 * 1024 * 1024, 50));
......@@ -1174,7 +1179,8 @@ void UpdateHistograms(const ThreadHeapStatsCollector::Event& event) {
CustomCountHistogram, atomic_marking_phase_histogram, \
("BlinkGC.AtomicPhaseMarking_" #GCReason, 0, 10000, 50)); \
atomic_marking_phase_histogram.Count( \
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseMarking]); \
event.scope_data[ThreadHeapStatsCollector::kAtomicPhaseMarking] \
.InMilliseconds()); \
DEFINE_STATIC_LOCAL(CustomCountHistogram, collection_rate_histogram, \
("BlinkGC.CollectionRate_" #GCReason, 1, 100, 20)); \
collection_rate_histogram.Count(collection_rate_percent); \
......@@ -1523,8 +1529,7 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
if (SweepForbidden())
return;
double start_total_collect_garbage_time =
WTF::CurrentTimeTicksInMilliseconds();
TimeTicks start_total_collect_garbage_time = WTF::CurrentTimeTicks();
RUNTIME_CALL_TIMER_SCOPE_IF_ISOLATE_EXISTS(
GetIsolate(), RuntimeCallStats::CounterId::kCollectGarbage);
......@@ -1551,19 +1556,20 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
RunAtomicPause(stack_state, marking_type, sweeping_type, reason);
}
const double total_collect_garbage_time =
WTF::CurrentTimeTicksInMilliseconds() - start_total_collect_garbage_time;
const TimeDelta total_collect_garbage_time =
WTF::CurrentTimeTicks() - start_total_collect_garbage_time;
DEFINE_THREAD_SAFE_STATIC_LOCAL(
CustomCountHistogram, time_for_total_collect_garbage_histogram,
("BlinkGC.TimeForTotalCollectGarbage", 1, 10 * 1000, 50));
time_for_total_collect_garbage_histogram.Count(total_collect_garbage_time);
time_for_total_collect_garbage_histogram.Count(
total_collect_garbage_time.InMilliseconds());
#define COUNT_BY_GC_REASON(GCReason) \
case BlinkGC::k##GCReason: { \
DEFINE_THREAD_SAFE_STATIC_LOCAL( \
CustomCountHistogram, histogram, \
("BlinkGC.TimeForTotalCollectGarbage_" #GCReason, 0, 10000, 50)); \
histogram.Count(total_collect_garbage_time); \
histogram.Count(total_collect_garbage_time.InMilliseconds()); \
break; \
}
......@@ -1583,7 +1589,7 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
VLOG(1) << "[state:" << this << "]"
<< " CollectGarbage: time: " << std::setprecision(2)
<< total_collect_garbage_time << "ms"
<< total_collect_garbage_time.InMillisecondsF() << "ms"
<< " stack: " << StackStateString(stack_state)
<< " marking: " << MarkingTypeString(marking_type)
<< " sweeping: " << SweepingTypeString(sweeping_type)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment