Mir

Merge lp:~vanvugt/mir/fix-1343074-0.5 into lp:mir/0.5

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Cemil Azizoglu
Proposed branch: lp:~vanvugt/mir/fix-1343074-0.5
Merge into: lp:mir/0.5
Diff against target: 113 lines (+48/-8)
5 files modified
3rd_party/android-deps/std/Log.h (+4/-0)
3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp (+11/-8)
CMakeLists.txt (+4/-0)
tests/acceptance-tests/CMakeLists.txt (+1/-0)
tests/acceptance-tests/test_macros.cpp (+28/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1343074-0.5
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Needs Resubmitting
PS Jenkins bot (community) continuous-integration Needs Fixing
Andreas Pokorny (community) Approve
Kevin DuBois (community) Approve
Review via email: mp+227498@code.launchpad.net

Commit message

Stop Android logging from consuming significant CPU (on every input event).
(LP: #1343074)

Two things needed fixing:
  1. Verbose logging (ALOGV) is meant to be disabled (optimized out) unless
     debugging, but it wasn't ever being removed. This means expensive calls
     to ALOGV remained, for example in EventHub.cpp on every input event.
  2. Our own Mir version of __android_log_print was extremely inefficient,
     formatting log messages unconditionally even when they did not meet the
     reporting threshold and were never used.

Description of the change

Backported from development-branch.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Same failure in jenkins.

lgtm, nevertheless.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

The failure seems to be a general infrastructure problem. Not this branch.

Please wait and don't top approve this while we land an emergency fix today...
https://code.launchpad.net/~mir-team/mir/0.5/+merge/227627

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Since 0.5 will not be the RTM, no point in committing this. We should use devel until 0.6 is branched out.

review: Needs Resubmitting

Unmerged revisions

1784. By Daniel van Vugt

Merge latest 0.5 branch

1783. By Daniel van Vugt

Merge latest lp:mir/0.5

1782. By Daniel van Vugt

Stop Android logging from consuming significant CPU (on every input event).
(LP: #1343074)

Two things needed fixing:
  1. Verbose logging (ALOGV) is meant to be disabled (optimized out) unless
     debugging, but it wasn't ever being removed. This means expensive calls
     to ALOGV remained, for example in EventHub.cpp on every input event.
  2. Our own Mir version of __android_log_print was extremely inefficient,
     formatting log messages unconditionally even when they did not meet the
     reporting threshold and were never used.

1781. By Cemil Azizoglu

Manual-merge with lp:~mir-team/mir/enable-late-release-0.5-backport.

1780. By Daniel van Vugt

Mention another bug fix we forgot - LP: #1189775

1779. By Daniel van Vugt

changelog: Document enhancements for 0.5.0

1778. By Daniel van Vugt

Restore changelog entry for 0.4.1. If we do retain a separate packaging
branch then it will have to be present.

1777. By Daniel van Vugt

Revert unidentified changes introduced in r1774. If anyone finds they need
them we can add them back in, with some explanation.

1776. By kevin gunn

update changelog

1775. By Cemil Azizoglu

Now change it to 0.5.0 to resolve the conflict.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-deps/std/Log.h'
2--- 3rd_party/android-deps/std/Log.h 2013-05-03 22:53:02 +0000
3+++ 3rd_party/android-deps/std/Log.h 2014-07-24 03:11:52 +0000
4@@ -61,8 +61,12 @@
5 * Simplified macro to send a verbose log message using the current LOG_TAG.
6 */
7 #ifndef ALOGV
8+#if LOG_NDEBUG // Per Android, optimize out verbose messages when LOG_NDEBUG=1
9+#define ALOGV(...) ((void)0)
10+#else
11 #define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
12 #endif
13+#endif
14
15 /*
16 * Simplified macro to send a debug log message using the current LOG_TAG.
17
18=== modified file '3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp'
19--- 3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp 2013-09-24 18:04:03 +0000
20+++ 3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp 2014-07-24 03:11:52 +0000
21@@ -154,11 +154,7 @@
22
23 extern "C" int __android_log_print(int prio, const char *tag, const char *fmt, ...)
24 {
25- char buffer[1024] = {'0'};
26- va_list ap;
27- va_start(ap, fmt);
28- int result = vsnprintf(buffer, sizeof buffer - 1, fmt, ap);
29- va_end(ap);
30+ int result = 0;
31
32 if (gLogState.globalMinPriority == ANDROID_LOG_UNKNOWN) {
33 configureInitialState(&gLogState);
34@@ -177,9 +173,16 @@
35 }
36
37 if (prio >= minPrio) {
38- char taggedBuffer[1024];
39- sprintf(taggedBuffer, "[%s]%s", tag, buffer);
40- mir::write_to_log(prio, taggedBuffer);
41+ char buffer[1024];
42+ int max = sizeof buffer - 1;
43+ int tagend = snprintf(buffer, max, "[%s]", tag);
44+
45+ va_list ap;
46+ va_start(ap, fmt);
47+ result = vsnprintf(buffer+tagend, max - tagend, fmt, ap);
48+ va_end(ap);
49+
50+ mir::write_to_log(prio, buffer);
51 } else {
52 // filter out log message
53 }
54
55=== modified file 'CMakeLists.txt'
56--- CMakeLists.txt 2014-07-16 04:59:13 +0000
57+++ CMakeLists.txt 2014-07-24 03:11:52 +0000
58@@ -88,6 +88,10 @@
59 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
60 endif()
61
62+# Define LOG_NDEBUG=1 to ensure Android ALOGV calls are not compiled in to
63+# consume CPU time...
64+add_definitions(-DLOG_NDEBUG=1)
65+
66 enable_testing()
67
68 include_directories(include/shared)
69
70=== modified file 'tests/acceptance-tests/CMakeLists.txt'
71--- tests/acceptance-tests/CMakeLists.txt 2014-07-11 14:04:15 +0000
72+++ tests/acceptance-tests/CMakeLists.txt 2014-07-24 03:11:52 +0000
73@@ -39,6 +39,7 @@
74 test_large_messages.cpp
75 test_client_surface_visibility.cpp
76 test_client_with_custom_display_config_deadlock.cpp
77+ test_macros.cpp
78 ${GENERATED_PROTOBUF_SRCS}
79 ${GENERATED_PROTOBUF_HDRS}
80 )
81
82=== added file 'tests/acceptance-tests/test_macros.cpp'
83--- tests/acceptance-tests/test_macros.cpp 1970-01-01 00:00:00 +0000
84+++ tests/acceptance-tests/test_macros.cpp 2014-07-24 03:11:52 +0000
85@@ -0,0 +1,28 @@
86+/*
87+ * Copyright © 2014 Canonical Ltd.
88+ *
89+ * This program is free software: you can redistribute it and/or modify
90+ * it under the terms of the GNU General Public License version 3 as
91+ * published by the Free Software Foundation.
92+ *
93+ * This program is distributed in the hope that it will be useful,
94+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
95+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+ * GNU General Public License for more details.
97+ *
98+ * You should have received a copy of the GNU General Public License
99+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
100+ *
101+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
102+ */
103+
104+#include "cutils/log.h" // Get the final value of LOG_NDEBUG
105+#include <gtest/gtest.h>
106+
107+TEST(Macros, android_verbose_logging_is_disabled)
108+{
109+ // Ensure verbose logging (ALOGV) is removed. It requires significant
110+ // CPU time to constantly format some verbose messages...
111+ // This is a regression test for performance bug LP: #1343074.
112+ EXPECT_EQ(1, LOG_NDEBUG);
113+}

Subscribers

People subscribed via source and target branches