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

Method GetBuffersToFree

be/src/runtime/bufferpool/free-list.h:79–91  ·  view source on GitHub ↗

Get the 'num_buffers' buffers with the highest memory address from the list to free. The average time complexity is n log n, where n is the current size of the list.

Source from the content-addressed store, hash-verified

77 /// free. The average time complexity is n log n, where n is the current size of the
78 /// list.
79 vector<BufferHandle> GetBuffersToFree(int64_t num_buffers) {
80 vector<BufferHandle> buffers;
81 DCHECK_LE(num_buffers, free_list_.size());
82 // Sort the list so we can free the buffers with higher memory addresses.
83 // Note that the sorted list is still a valid min-heap.
84 std::sort(free_list_.begin(), free_list_.end(), SortCompare);
85
86 for (int64_t i = 0; i < num_buffers; ++i) {
87 buffers.emplace_back(std::move(free_list_.back()));
88 free_list_.pop_back();
89 }
90 return buffers;
91 }
92
93 /// Returns the number of buffers currently in the list.
94 int64_t Size() const { return free_list_.size(); }

Callers 6

~FreeBufferArenaMethod · 0.80
FreeSystemMemoryMethod · 0.80
MaintenanceMethod · 0.80
TEST_FFunction · 0.80
DoFreeFunction · 0.80
FreeListBenchmarkFunction · 0.80

Calls 5

sortFunction · 0.85
moveFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

TEST_FFunction · 0.64