[PATCH] D49363: [XRay][compiler-rt] Segmented Array: Simplify and Optimise

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 00:26:21 PDT 2018


dberris created this revision.
dberris added reviewers: kpw, eizan.

This is a follow-on to https://reviews.llvm.org/D49217 which simplifies and optimises the
implementation of the segmented array. In this patch we co-locate the
book-keeping for segments in the `__xray::Array<T>` with the data it's
managing. We take the chance in this patch to actually rename `Chunk` to
`Segment` to better align with the high-level description of the
segmented array.

With measurements using benchmarks landed in https://reviews.llvm.org/D48879, we've identified
that calls to `pthread_getspecific` started dominating the cycles, which
led us to revert the change made in https://reviews.llvm.org/D49217 to use C++ thread_local
initialisation instead (it reduces the cost by a huge margin, since we
save one PLT-based call to pthread functions in the hot path). In
particular, this is in `__xray::getThreadLocalData()`.

We also took the opportunity to remove the least-common-multiple based
calculation and instead pack as much data into segments of the array.
This greatly simplifies the API of the container which hides as much of
the implementation details as possible. For instance, we calculate the
number of elements we need for the each segment internally in the Array
instead of making it part of the type.

With the changes here, we're able to get a measurable improvement on the
performance of profiling mode on top of what https://reviews.llvm.org/D48879 already provides.

Depends on https://reviews.llvm.org/D48879.


https://reviews.llvm.org/D49363

Files:
  compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
  compiler-rt/lib/xray/xray_function_call_trie.h
  compiler-rt/lib/xray/xray_profile_collector.cc
  compiler-rt/lib/xray/xray_profiling.cc
  compiler-rt/lib/xray/xray_segmented_array.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49363.155623.patch
Type: text/x-patch
Size: 33001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180716/3ceb69c6/attachment.bin>


More information about the llvm-commits mailing list