[PATCH] D54989: [XRay] Move-only Allocator, FunctionCallTrie, and Array

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 21:36:04 PST 2018


dberris created this revision.
dberris added a reviewer: mboerger.
Herald added a reviewer: jfb.
Herald added a subscriber: jfb.

This change makes the allocator and function call trie implementations
move-aware and remove the FunctionCallTrie's reliance on a
heap-allocated set of allocators.

The change makes it possible to always have storage associated with
Allocator instances, not necessarily having heap-allocated memory
obtainable from these allocator instances. We also use thread-local
uninitialised storage.

We've also re-worked the segmented array implementation to have more
precondition and post-condition checks when built in debug mode. This
enables us to better implement some of the operations with surrounding
documentation as well. The `trim` algorithm now has more documentation
on the implementation, reducing the requirement to handle special
conditions, and being more rigorous on the computations involved.

In this change we also introduce an initialisation guard, through which
we prevent an initialisation operation from racing with a cleanup
operation.

We also ensure that the ThreadTries array is not destroyed while copies
into the elements are still being performed by other threads submitting
profiles.

Note that this change still has an issue with accessing thread-local
storage from signal handlers that are instrumented with XRay. We also
learn that with the testing of this patch, that there will be cases
where calls to mmap(...) (through internal_mmap(...)) might be called in
signal handlers, but are not async-signal-safe. Subsequent patches will
address this, by re-using the `BufferQueue` type used in the FDR mode
implementation for pre-allocated memory segments per active, tracing
thread.

We still want to land this change despite the known issues, with fixes
forthcoming.


https://reviews.llvm.org/D54989

Files:
  compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc
  compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
  compiler-rt/lib/xray/xray_allocator.h
  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: D54989.175624.patch
Type: text/x-patch
Size: 62117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181128/de305ff7/attachment.bin>


More information about the llvm-commits mailing list