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

Commit 1d9c7e72 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

logd: simpleperf inspired optimizations

memset is hot on log writes with too much overhead, not required.

Bug: 24444530
Bug: 23685592
Change-Id: Ibe3c83abca6774fc79a3be461f2f1585f4a9b1ff
parent 461a2954
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ bool LogListener::onDataAvailable(SocketClient *cli) {
    char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time)
        + LOGGER_ENTRY_MAX_PAYLOAD];
    struct iovec iov = { buffer, sizeof(buffer) };
    memset(buffer, 0, sizeof(buffer));

    char control[CMSG_SPACE(sizeof(struct ucred))];
    struct msghdr hdr = {
@@ -60,6 +59,9 @@ bool LogListener::onDataAvailable(SocketClient *cli) {

    int socket = cli->getSocket();

    // To clear the entire buffer is secure/safe, but this contributes to 1.68%
    // overhead under logging load. We are safe because we check counts.
    // memset(buffer, 0, sizeof(buffer));
    ssize_t n = recvmsg(socket, &hdr, 0);
    if (n <= (ssize_t)(sizeof(android_log_header_t))) {
        return false;