[memlog] Thread names are truncated |
|||||
Issue description
On Linux/Android memlog gets thread names from two sources:
1. ThreadIdNameManager::SetNameCallback, for threads created after tracing has started.
2. prctl(PR_GET_NAME), as a fallback, for threads that were started before tracing.
The problem is that PR_GET_NAME is limited to 15 chars, so we end up with thread names like "TaskSchedulerBa" (instead of TaskSchedulerBackgroundBlockingWorker).
Additionally there is a problem with Java threads, which always go through PR_GET_NAME and are always truncated ("SafetyNetHandle" instead of "SafetyNetHandlerThread").
I propose we try these sources when determining thread names:
1. Native thread name (base::ThreadIdNameManager)
2. Java thread name (java.lang.Thread.currentThread().getName())
3. prctl(PR_GET_NAME)
Additionally, it would be nice to format thread names as "[Thread: <thread name>]" to visually distinguish them from stack frames.
,
Feb 7 2018
,
Mar 15 2018
,
Mar 21 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6a6a41a3525c5844d8f26d0a65d099522a85516c commit 6a6a41a3525c5844d8f26d0a65d099522a85516c Author: erikchen <erikchen@chromium.org> Date: Wed Mar 21 20:03:53 2018 Hook up platform thread names for heap profiling. In order to accomplish this, I added a non-lock based mechanism [TLS] to acquire the name of the current thread. In the process, I updated the SetName() API to only allow name-setting for the current thread. Bug: 809221 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel Change-Id: Ic3e63c396c6ddda6da4b8d74abb3083ff22cfa8c Reviewed-on: https://chromium-review.googlesource.com/969403 Commit-Queue: Erik Chen <erikchen@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/master@{#544811} [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/platform_thread_android.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/platform_thread_fuchsia.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/platform_thread_linux.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/platform_thread_mac.mm [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/platform_thread_win.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/thread_id_name_manager.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/base/threading/thread_id_name_manager.h [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/cc/blink/test/cc_blink_test_suite.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/cc/test/cc_test_suite.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/chrome/common/profiling/memlog_allocator_shim.cc [modify] https://crrev.com/6a6a41a3525c5844d8f26d0a65d099522a85516c/components/viz/test/viz_test_suite.cc
,
Mar 27 2018
,
Mar 27 2018
Did you fix Java thread names too?
,
Mar 27 2018
That shouldn't be necessary since we always can get ThreadIdNameManager names, right?
,
Mar 27 2018
I think ThreadIdNameManager only tracks native stuff, it doesn't know about Java threads. So if a thread created from Java allocates, we'll end up using PR_GET_NAME path (i.e. get truncated name).
,
Mar 27 2018
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by dskiba@chromium.org
, Feb 5 2018