[fuchsia] Avoid unnecessary zx_clock_get(ZX_CLOCK_THREAD, ...) calls
When system tracing is enabled on the Fuchsia platform, avoid calling |OS::GetCurrentThreadCPUMicros|. The thread timestamp values are discarded later, so querying them is wasteful w.r.t. both time and trace buffer space. Change-Id: I400075c89e69ddde6b032808859826c95f029008 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149395 Reviewed-by: Siva Annamalai <asiva@google.com> Auto-Submit: Nathan Rogers <nathanrogers@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
97954adac0
commit
ff13c4e31a
@@ -63,6 +63,11 @@ class OS {
|
||||
// NOTE: This function will return -1 on OSs that are not supported.
|
||||
static int64_t GetCurrentThreadCPUMicros();
|
||||
|
||||
// If the tracing/timeline configuration on the current OS supports thread
|
||||
// timestamps, returns the same value as |GetCurrentThreadCPUMicros|.
|
||||
// Otherwise, returns -1.
|
||||
static int64_t GetCurrentThreadCPUMicrosForTimeline();
|
||||
|
||||
// Returns the activation frame alignment constraint or one if
|
||||
// the platform doesn't care. Guaranteed to be a power of two.
|
||||
static intptr_t ActivationFrameAlignment();
|
||||
|
||||
@@ -177,6 +177,10 @@ int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentThreadCPUMicrosForTimeline() {
|
||||
return OS::GetCurrentThreadCPUMicros();
|
||||
}
|
||||
|
||||
// TODO(5411554): May need to hoist these architecture dependent code
|
||||
// into a architecture specific file e.g: os_ia32_linux.cc
|
||||
intptr_t OS::ActivationFrameAlignment() {
|
||||
|
||||
@@ -287,6 +287,13 @@ int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
return now / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
// On Fuchsia, thread timestamp values are not used in the tracing/timeline
|
||||
// integration. Because of this, we try to avoid querying them, since doing so
|
||||
// has both a runtime and trace buffer storage cost.
|
||||
int64_t OS::GetCurrentThreadCPUMicrosForTimeline() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO(5411554): May need to hoist these architecture dependent code
|
||||
// into a architecture specific file e.g: os_ia32_fuchsia.cc
|
||||
intptr_t OS::ActivationFrameAlignment() {
|
||||
|
||||
@@ -492,6 +492,10 @@ int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentThreadCPUMicrosForTimeline() {
|
||||
return OS::GetCurrentThreadCPUMicros();
|
||||
}
|
||||
|
||||
// TODO(5411554): May need to hoist these architecture dependent code
|
||||
// into a architecture specific file e.g: os_ia32_linux.cc
|
||||
intptr_t OS::ActivationFrameAlignment() {
|
||||
|
||||
@@ -127,6 +127,10 @@ int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentThreadCPUMicrosForTimeline() {
|
||||
return OS::GetCurrentThreadCPUMicros();
|
||||
}
|
||||
|
||||
intptr_t OS::ActivationFrameAlignment() {
|
||||
#if HOST_OS_IOS
|
||||
#if TARGET_ARCH_ARM
|
||||
|
||||
@@ -174,6 +174,10 @@ int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentThreadCPUMicrosForTimeline() {
|
||||
return OS::GetCurrentThreadCPUMicros();
|
||||
}
|
||||
|
||||
intptr_t OS::ActivationFrameAlignment() {
|
||||
#if defined(TARGET_ARCH_ARM64)
|
||||
return 16;
|
||||
|
||||
@@ -1581,7 +1581,7 @@ void DartTimelineEventHelpers::ReportTaskEvent(Thread* thread,
|
||||
(phase[0] == 'B') || (phase[0] == 'E'));
|
||||
ASSERT(phase[1] == '\0');
|
||||
const int64_t start = OS::GetCurrentMonotonicMicros();
|
||||
const int64_t start_cpu = OS::GetCurrentThreadCPUMicros();
|
||||
const int64_t start_cpu = OS::GetCurrentThreadCPUMicrosForTimeline();
|
||||
switch (phase[0]) {
|
||||
case 'n':
|
||||
event->AsyncInstant(name, id, start);
|
||||
|
||||
+12
-9
@@ -248,11 +248,13 @@ class TimelineEvent {
|
||||
int64_t async_id,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros());
|
||||
|
||||
void DurationBegin(const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
|
||||
void DurationEnd(int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
|
||||
void DurationBegin(
|
||||
const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicrosForTimeline());
|
||||
void DurationEnd(
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicrosForTimeline());
|
||||
|
||||
void Instant(const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros());
|
||||
@@ -263,13 +265,14 @@ class TimelineEvent {
|
||||
int64_t thread_start_micros = -1,
|
||||
int64_t thread_end_micros = -1);
|
||||
|
||||
void Begin(const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
|
||||
void Begin(
|
||||
const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicrosForTimeline());
|
||||
|
||||
void End(const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros(),
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
|
||||
int64_t thread_micros = OS::GetCurrentThreadCPUMicrosForTimeline());
|
||||
|
||||
void Counter(const char* label,
|
||||
int64_t micros = OS::GetCurrentMonotonicMicros());
|
||||
|
||||
Reference in New Issue
Block a user