зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358074 (part 3) - Don't measure process creation time on every profiler_start() call. r=mstange.
We measure it in profiler_init(); there's not point overwriting it with the same value every time profiler_start() is called! The patch also renames mStartTime as mProcessStartTime to make things clearer.
This commit is contained in:
Родитель
8b8a0629d2
Коммит
4f297049d6
|
@ -171,7 +171,7 @@ public:
|
|||
type_ name_(LockRef) const { return m##name_; } \
|
||||
void Set##name_(LockRef, type_ a##name_) { m##name_ = a##name_; }
|
||||
|
||||
GET_AND_SET(TimeStamp, StartTime)
|
||||
GET_AND_SET(TimeStamp, ProcessStartTime)
|
||||
|
||||
GET_AND_SET(int, Entries)
|
||||
|
||||
|
@ -232,8 +232,8 @@ public:
|
|||
#undef GET_AND_SET
|
||||
|
||||
private:
|
||||
// When profiler_init() or profiler_start() was most recently called.
|
||||
mozilla::TimeStamp mStartTime;
|
||||
// The time that the process started.
|
||||
mozilla::TimeStamp mProcessStartTime;
|
||||
|
||||
// The number of entries in mBuffer. Zeroed when the profiler is inactive.
|
||||
int mEntries;
|
||||
|
@ -1077,7 +1077,8 @@ Tick(PS::LockRef aLock, ProfileBuffer* aBuffer, const TickSample& aSample)
|
|||
{
|
||||
aBuffer->addTagThreadId(aSample.mThreadId, aSample.mLastSample);
|
||||
|
||||
mozilla::TimeDuration delta = aSample.mTimeStamp - gPS->StartTime(aLock);
|
||||
mozilla::TimeDuration delta =
|
||||
aSample.mTimeStamp - gPS->ProcessStartTime(aLock);
|
||||
aBuffer->addTag(ProfileBufferEntry::Time(delta.ToMilliseconds()));
|
||||
|
||||
NotNull<PseudoStack*> pseudoStack = aSample.mPseudoStack;
|
||||
|
@ -1192,7 +1193,7 @@ StreamTaskTracer(PS::LockRef aLock, SpliceableJSONWriter& aWriter)
|
|||
aWriter.StartArrayProperty("data");
|
||||
{
|
||||
UniquePtr<nsTArray<nsCString>> data =
|
||||
mozilla::tasktracer::GetLoggedData(gPS->StartTime(aLock));
|
||||
mozilla::tasktracer::GetLoggedData(gPS->ProcessStartTime(aLock));
|
||||
for (uint32_t i = 0; i < data->Length(); ++i) {
|
||||
aWriter.StringElement((data->ElementAt(i)).get());
|
||||
}
|
||||
|
@ -1241,10 +1242,10 @@ StreamMetaJSCustomObject(PS::LockRef aLock, SpliceableJSONWriter& aWriter)
|
|||
aWriter.IntProperty("asyncstack", asyncStacks);
|
||||
|
||||
// The "startTime" field holds the number of milliseconds since midnight
|
||||
// January 1, 1970 GMT. This grotty code computes (Now - (Now - StartTime))
|
||||
// to convert gPS->StartTime() into that form.
|
||||
// January 1, 1970 GMT. This grotty code computes (Now - (Now -
|
||||
// ProcessStartTime)) to convert gPS->ProcessStartTime() into that form.
|
||||
mozilla::TimeDuration delta =
|
||||
mozilla::TimeStamp::Now() - gPS->StartTime(aLock);
|
||||
mozilla::TimeStamp::Now() - gPS->ProcessStartTime(aLock);
|
||||
aWriter.DoubleProperty(
|
||||
"startTime", static_cast<double>(PR_Now()/1000.0 - delta.ToMilliseconds()));
|
||||
|
||||
|
@ -1390,16 +1391,16 @@ locked_profiler_stream_json_for_this_process(PS::LockRef aLock, SpliceableJSONWr
|
|||
if (!info->IsBeingProfiled()) {
|
||||
continue;
|
||||
}
|
||||
info->StreamJSON(gPS->Buffer(aLock), aWriter, gPS->StartTime(aLock),
|
||||
aSinceTime);
|
||||
info->StreamJSON(gPS->Buffer(aLock), aWriter,
|
||||
gPS->ProcessStartTime(aLock), aSinceTime);
|
||||
}
|
||||
|
||||
const PS::ThreadVector& deadThreads = gPS->DeadThreads(aLock);
|
||||
for (size_t i = 0; i < deadThreads.size(); i++) {
|
||||
ThreadInfo* info = deadThreads.at(i);
|
||||
MOZ_ASSERT(info->IsBeingProfiled());
|
||||
info->StreamJSON(gPS->Buffer(aLock), aWriter, gPS->StartTime(aLock),
|
||||
aSinceTime);
|
||||
info->StreamJSON(gPS->Buffer(aLock), aWriter,
|
||||
gPS->ProcessStartTime(aLock), aSinceTime);
|
||||
}
|
||||
|
||||
#if defined(PROFILE_JAVA)
|
||||
|
@ -1467,7 +1468,7 @@ ProfilerMarker::GetTime() const {
|
|||
}
|
||||
|
||||
void ProfilerMarker::StreamJSON(SpliceableJSONWriter& aWriter,
|
||||
const TimeStamp& aStartTime,
|
||||
const TimeStamp& aProcessStartTime,
|
||||
UniqueStacks& aUniqueStacks) const
|
||||
{
|
||||
// Schema:
|
||||
|
@ -1483,7 +1484,7 @@ void ProfilerMarker::StreamJSON(SpliceableJSONWriter& aWriter,
|
|||
if (mPayload) {
|
||||
aWriter.StartObjectElement();
|
||||
{
|
||||
mPayload->StreamPayload(aWriter, aStartTime, aUniqueStacks);
|
||||
mPayload->StreamPayload(aWriter, aProcessStartTime, aUniqueStacks);
|
||||
}
|
||||
aWriter.EndObject();
|
||||
}
|
||||
|
@ -1654,9 +1655,9 @@ SamplerThread::Run()
|
|||
// cheaper than taking a new sample.
|
||||
if (info->Stack()->CanDuplicateLastSampleDueToSleep()) {
|
||||
bool dup_ok =
|
||||
gPS->Buffer(lock)->DuplicateLastSample(info->ThreadId(),
|
||||
gPS->StartTime(lock),
|
||||
info->LastSample());
|
||||
gPS->Buffer(lock)->DuplicateLastSample(
|
||||
info->ThreadId(), gPS->ProcessStartTime(lock),
|
||||
info->LastSample());
|
||||
if (dup_ok) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1986,7 +1987,7 @@ profiler_init(void* aStackTop)
|
|||
gPS = new PS();
|
||||
|
||||
bool ignore;
|
||||
gPS->SetStartTime(lock, mozilla::TimeStamp::ProcessCreation(ignore));
|
||||
gPS->SetProcessStartTime(lock, mozilla::TimeStamp::ProcessCreation(ignore));
|
||||
|
||||
locked_register_thread(lock, kMainThreadName, aStackTop);
|
||||
|
||||
|
@ -2319,9 +2320,6 @@ locked_profiler_start(PS::LockRef aLock, int aEntries, double aInterval,
|
|||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
MOZ_RELEASE_ASSERT(gPS && !gPS->IsActive(aLock));
|
||||
|
||||
bool ignore;
|
||||
gPS->SetStartTime(aLock, mozilla::TimeStamp::ProcessCreation(ignore));
|
||||
|
||||
// Fall back to the default value if the passed-in value is unreasonable.
|
||||
int entries = aEntries > 0 ? aEntries : PROFILE_DEFAULT_ENTRIES;
|
||||
gPS->SetEntries(aLock, entries);
|
||||
|
@ -2837,7 +2835,7 @@ profiler_time()
|
|||
PS::AutoLock lock(gPSMutex);
|
||||
|
||||
mozilla::TimeDuration delta =
|
||||
mozilla::TimeStamp::Now() - gPS->StartTime(lock);
|
||||
mozilla::TimeStamp::Now() - gPS->ProcessStartTime(lock);
|
||||
return delta.ToMilliseconds();
|
||||
}
|
||||
|
||||
|
@ -2966,7 +2964,7 @@ locked_profiler_add_marker(PS::LockRef aLock, const char* aMarker,
|
|||
mozilla::TimeStamp origin = (payload && !payload->GetStartTime().IsNull())
|
||||
? payload->GetStartTime()
|
||||
: mozilla::TimeStamp::Now();
|
||||
mozilla::TimeDuration delta = origin - gPS->StartTime(aLock);
|
||||
mozilla::TimeDuration delta = origin - gPS->ProcessStartTime(aLock);
|
||||
stack->addMarker(aMarker, payload.release(), delta.ToMilliseconds());
|
||||
}
|
||||
|
||||
|
@ -3077,7 +3075,8 @@ profiler_clear_js_context()
|
|||
ThreadInfo* info = FindLiveThreadInfo(lock);
|
||||
MOZ_RELEASE_ASSERT(info);
|
||||
if (info->IsBeingProfiled()) {
|
||||
info->FlushSamplesAndMarkers(gPS->Buffer(lock), gPS->StartTime(lock));
|
||||
info->FlushSamplesAndMarkers(gPS->Buffer(lock),
|
||||
gPS->ProcessStartTime(lock));
|
||||
}
|
||||
|
||||
gPS->SetIsPaused(lock, false);
|
||||
|
|
|
@ -289,8 +289,8 @@ PROFILER_FUNC(bool profiler_thread_is_sleeping(), false)
|
|||
// not.
|
||||
PROFILER_FUNC_VOID(profiler_js_interrupt_callback())
|
||||
|
||||
// Gets the time since the last profiler_init() or profiler_start() call.
|
||||
// Operates the same whether the profiler is active or inactive.
|
||||
// The number of milliseconds since the process started. Operates the same
|
||||
// whether the profiler is active or inactive.
|
||||
PROFILER_FUNC(double profiler_time(), 0)
|
||||
|
||||
PROFILER_FUNC_VOID(profiler_log(const char *str))
|
||||
|
|
Загрузка…
Ссылка в новой задаче