From 142b43d4ab47f8f98748a9d560934a1f8f90c898 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Wed, 28 Dec 2016 10:30:57 -0800 Subject: [PATCH] liblog: BM_log_latency improvement This reduces BM_log_latency from ~300ns to ~100ns. Because, well, we read the clock earlier and that is what BM_log_latency tries to measure. The one major improvement in the switch from kernel logger to user space logger was that we picked up the timestamp in the context of the caller before doing anything else, but alas changes over time neglected this fact and placed isloggable checking ahead of this important fact. Test: liblog_benchmarks, check results Change-Id: I4bc9fc3cf8b1659e88417d967b1d0f3743f9e456 --- liblog/logger_write.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liblog/logger_write.c b/liblog/logger_write.c index f19c3ab27..1a2d50612 100644 --- a/liblog/logger_write.c +++ b/liblog/logger_write.c @@ -262,6 +262,8 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr) } #if defined(__ANDROID__) + clock_gettime(android_log_clockid(), &ts); + if (log_id == LOG_ID_SECURITY) { if (vec[0].iov_len < 4) { return -EINVAL; @@ -351,8 +353,6 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr) return -EPERM; } } - - clock_gettime(android_log_clockid(), &ts); #else /* simulate clock_gettime(CLOCK_REALTIME, &ts); */ {