liblog: add __attribute__((uninitialized)) to liblog buffers
These buffers are immediately written into with *printf() and are in
the hot path, so do not initialize them. This saves ~70ns off of each
log message, which is ~14% of the overhead within
__android_log_print() when writing to a no-op logger.
Test: liblog benchmarks
Change-Id: I2b898e72c75b57bc63fee565b49a4e00e377ed1a
diff --git a/liblog/logger_write.cpp b/liblog/logger_write.cpp
index cf82e0f..1b6b0c6 100644
--- a/liblog/logger_write.cpp
+++ b/liblog/logger_write.cpp
@@ -348,7 +348,7 @@
return 0;
}
- char buf[LOG_BUF_SIZE];
+ __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
@@ -366,7 +366,7 @@
}
va_list ap;
- char buf[LOG_BUF_SIZE];
+ __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
va_start(ap, fmt);
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
@@ -386,7 +386,7 @@
}
va_list ap;
- char buf[LOG_BUF_SIZE];
+ __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
va_start(ap, fmt);
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
@@ -398,7 +398,7 @@
}
void __android_log_assert(const char* cond, const char* tag, const char* fmt, ...) {
- char buf[LOG_BUF_SIZE];
+ __attribute__((uninitialized)) char buf[LOG_BUF_SIZE];
if (fmt) {
va_list ap;