MCPcopy Create free account
hub / github.com/apache/impala / TEST_F

Function TEST_F

be/src/runtime/bufferpool/suballocator-test.cc:133–167  ·  view source on GitHub ↗

Basic test to make sure that we can make multiple suballocations of the same size while using the expected number of buffers.

Source from the content-addressed store, hash-verified

131/// Basic test to make sure that we can make multiple suballocations of the same size
132/// while using the expected number of buffers.
133TEST_F(SuballocatorTest, SameSizeAllocations) {
134 const int64_t TOTAL_MEM = TEST_BUFFER_LEN * 100;
135 InitPool(TEST_BUFFER_LEN, TOTAL_MEM);
136 BufferPool::ClientHandle* client;
137 RegisterClient(&global_reservation_, &client);
138 Suballocator allocator(buffer_pool(), client, TEST_BUFFER_LEN);
139 vector<unique_ptr<Suballocation>> allocs;
140
141 // Make suballocations smaller than the buffer size.
142 const int64_t ALLOC_SIZE = TEST_BUFFER_LEN / 4;
143 int64_t allocated_mem = 0;
144 while (allocated_mem < TOTAL_MEM) {
145 allocs.emplace_back();
146 ASSERT_OK(allocator.Allocate(ALLOC_SIZE, &allocs.back()));
147 ASSERT_TRUE(allocs.back() != nullptr) << ALLOC_SIZE << " " << allocated_mem << " "
148 << global_reservation_.DebugString();
149 allocated_mem += ALLOC_SIZE;
150 }
151
152 // Attempts to allocate more memory should fail gracefully.
153 const int64_t MAX_ALLOC_SIZE = 1L << 24;
154 for (int alloc_size = 1; alloc_size <= MAX_ALLOC_SIZE; alloc_size *= 2) {
155 unique_ptr<Suballocation> failed_alloc;
156 ASSERT_OK(allocator.Allocate(alloc_size, &failed_alloc));
157 ASSERT_TRUE(failed_alloc == nullptr) << alloc_size << " " << allocated_mem << " "
158 << global_reservation_.DebugString();
159 }
160 AssertMemoryValid(allocs);
161
162 // Check that reservation usage matches the amount allocated.
163 EXPECT_EQ(client->GetUsedReservation(), allocated_mem)
164 << global_reservation_.DebugString();
165 FreeAllocations(&allocator, &allocs);
166 ExpectReservationUnused(client);
167}
168
169/// Check behaviour of zero-length allocation.
170TEST_F(SuballocatorTest, ZeroLengthAllocation) {

Callers

nothing calls this directly

Calls 14

moveFunction · 0.85
maxFunction · 0.85
shuffleFunction · 0.85
push_backMethod · 0.80
AllocateMethod · 0.45
DebugStringMethod · 0.45
GetUsedReservationMethod · 0.45
lenMethod · 0.45
FreeMethod · 0.45
okMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected