Skip to content

Commit d7ce58b

Browse files
committed
art: Disable debug tracing on production builds
When opening and closing activities in Settings, a significant amount of CPU time is spent checking whether ATrace tags are enabled, as measured by simpleperf: 0.12% /system/lib64/libcutils.so atrace_get_enabled_tag ART debug tracing (via PALette) is responsible for a significant portion of the time spent in the checks: 0.10% 0.07% /system/lib64/libcutils.so atrace_get_enabled_tags | -- atrace_get_enabled_tags | |--30.47%-- PaletteTraceEnabled | | | |--96.11%-- art::Monitor::TryLock(art::Thread*, bool) | | void art::Monitor::Lock<(art::LockReason)1>(art::Thread*) | | art::Monitor::MonitorEnter(art::Thread*, art::ObjPtr<art::mirror::Object>, bool) | | artLockObjectFromCode | | art_quick_lock_object_no_inline | | |--8.63%-- [hit in function] | | | | | |--18.62%-- android.os.Parcel.obtain | |--2.44%-- PaletteTraceIntegerValue | | | |--25.86%-- art::mirror::String::AllocFromModifiedUtf8(art::Thread*, int, char const*, int) | | | |--22.90%-- art::mirror::Object* art::gc::Heap::AllocLargeObject<false, art::mirror::SetLengthVisitor>(art::Thread*, art::ObjPtr<art::mirror::Class>*, unsigned long, art::mirror::SetLengthVisitor const&) | | | |--19.85%-- artAllocArrayFromCodeResolvedRegionTLAB | | | |--19.71%-- art::mirror::String::AllocFromUtf16(art::Thread*, int, unsigned short const*) | | | --11.70%-- art::mirror::Object::Clone(art::Handle<art::mirror::Object>, art::Thread*) We aren't going to use ATrace for ART in production systems, so disable debug tracing in non-debug builds. Test: simpleperf record -a; verify that PaletteTraceEnabled no longer appears under atrace_get_enabled_tags Change-Id: If5cdb18adb17b04f5f7eb7c59cfb3f9ceaecb5be
1 parent b49effd commit d7ce58b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

libartbase/base/systrace.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,37 @@
2727
namespace art {
2828

2929
inline bool ATraceEnabled() {
30+
#ifdef NDEBUG
31+
return false;
32+
#else
3033
bool enabled = false;
3134
if (UNLIKELY(PaletteTraceEnabled(&enabled) == PALETTE_STATUS_OK && enabled)) {
3235
return true;
3336
} else {
3437
return false;
3538
}
39+
#endif
3640
}
3741

3842
inline void ATraceBegin(const char* name) {
43+
(void)name;
44+
#ifndef NDEBUG
3945
PaletteTraceBegin(name);
46+
#endif
4047
}
4148

4249
inline void ATraceEnd() {
50+
#ifndef NDEBUG
4351
PaletteTraceEnd();
52+
#endif
4453
}
4554

4655
inline void ATraceIntegerValue(const char* name, int32_t value) {
56+
(void)name;
57+
(void)value;
58+
#ifndef NDEBUG
4759
PaletteTraceIntegerValue(name, value);
60+
#endif
4861
}
4962

5063
class ScopedTrace {

0 commit comments

Comments
 (0)