Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3574c37f authored by Tom Cherry's avatar Tom Cherry
Browse files

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
parent e53f8b8f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
    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 @@ int __android_log_print(int prio, const char* tag, const char* fmt, ...) {
  }

  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 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fm
  }

  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 @@ int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fm
}

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;