HappenLee commented on code in PR #68399:
URL: https://github.com/apache/doris/pull/68399#discussion_r4216474281
##########
be/src/load/memtable/memtable.cpp:
##########
@@ -51,6 +51,26 @@ bvar::Adder<uint64_t>
g_flush_cuz_memtable_full("flush_cuz_memtable_full");
using namespace ErrorCode;
+namespace {
+
+// Share one tracked allocation across a batch. Allocating each row separately
also
+// retains an address record and a stack trace per row when memory diagnostics
are enabled.
+template <typename RowFactory>
+std::shared_ptr<RowInBlock[]> make_row_batch(size_t num_rows, RowFactory&&
make_row) {
+ if (num_rows == 1) {
Review Comment:
I suggest removing this single-row special case and always using the array
allocation below. For `num_rows == 1`, both paths still use one tracked
allocation and one control block. The special case saves array bookkeeping, but
adds a second allocation path and requires readers to understand a scalar-owned
object exposed through an array-typed aliasing `shared_ptr`.
The existing `SingleRowBatches` test verifies correctness, but does not
demonstrate a meaningful performance or memory benefit from this branch. Unless
there are measurements supporting it, the unified array path seems easier to
maintain. We should keep the single-row test to cover that path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]