diff options
author | Dean Michael Berris <dberris@google.com> | 2018-07-18 01:53:39 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2018-07-18 01:53:39 +0000 |
commit | 9d6b7a5f2bde677887f9fd4009e9915d3bafa7b6 (patch) | |
tree | c8ebe1526b0acb64de2a2bf32d8d0fcd74b12455 /compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc | |
parent | 1e3feb49e333520f9c16ea586a8edd5931f34063 (diff) | |
download | bcm5719-llvm-9d6b7a5f2bde677887f9fd4009e9915d3bafa7b6.tar.gz bcm5719-llvm-9d6b7a5f2bde677887f9fd4009e9915d3bafa7b6.zip |
[XRay][compiler-rt] Simplify Allocator Implementation
Summary:
This change simplifies the XRay Allocator implementation to self-manage
an mmap'ed memory segment instead of using the internal allocator
implementation in sanitizer_common.
We've found through benchmarks and profiling these benchmarks in D48879
that using the internal allocator in sanitizer_common introduces a
bottleneck on allocating memory through a central spinlock. This change
allows thread-local allocators to eliminate contention on the
centralized allocator.
To get the most benefit from this approach, we also use a managed
allocator for the chunk elements used by the segmented array
implementation. This gives us the chance to amortize the cost of
allocating memory when creating these internal segmented array data
structures.
We also took the opportunity to remove the preallocation argument from
the allocator API, simplifying the usage of the allocator throughout the
profiling implementation.
In this change we also tweak some of the flag values to reduce the
amount of maximum memory we use/need for each thread, when requesting
memory through mmap.
Depends on D48956.
Reviewers: kpw, eizan
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49217
llvm-svn: 337342
Diffstat (limited to 'compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc')
-rw-r--r-- | compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc b/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc index 6ad51aa148c..049ecfb07e0 100644 --- a/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc +++ b/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc @@ -19,8 +19,6 @@ namespace __xray { namespace { TEST(FunctionCallTrieTest, ConstructWithTLSAllocators) { - // FIXME: Support passing in configuration for allocators in the allocator - // constructors. profilingFlags()->setDefaults(); FunctionCallTrie::Allocators Allocators = FunctionCallTrie::InitAllocators(); FunctionCallTrie Trie(Allocators); @@ -47,6 +45,7 @@ TEST(FunctionCallTrieTest, EnterAndExitFunction) { } TEST(FunctionCallTrieTest, MissingFunctionEntry) { + profilingFlags()->setDefaults(); auto A = FunctionCallTrie::InitAllocators(); FunctionCallTrie Trie(A); Trie.exitFunction(1, 1); @@ -56,6 +55,7 @@ TEST(FunctionCallTrieTest, MissingFunctionEntry) { } TEST(FunctionCallTrieTest, NoMatchingEntersForExit) { + profilingFlags()->setDefaults(); auto A = FunctionCallTrie::InitAllocators(); FunctionCallTrie Trie(A); Trie.enterFunction(2, 1); @@ -63,16 +63,19 @@ TEST(FunctionCallTrieTest, NoMatchingEntersForExit) { Trie.exitFunction(1, 5); const auto &R = Trie.getRoots(); - ASSERT_TRUE(R.empty()); + ASSERT_FALSE(R.empty()); + EXPECT_EQ(R.size(), size_t{1}); } TEST(FunctionCallTrieTest, MissingFunctionExit) { + profilingFlags()->setDefaults(); auto A = FunctionCallTrie::InitAllocators(); FunctionCallTrie Trie(A); Trie.enterFunction(1, 1); const auto &R = Trie.getRoots(); - ASSERT_TRUE(R.empty()); + ASSERT_FALSE(R.empty()); + EXPECT_EQ(R.size(), size_t{1}); } TEST(FunctionCallTrieTest, MultipleRoots) { |