github-actions[bot] commented on code in PR #61535:
URL: https://github.com/apache/doris/pull/61535#discussion_r3123133983
##########
be/src/runtime/runtime_state.h:
##########
@@ -138,7 +138,41 @@ class RuntimeState {
const DescriptorTbl& desc_tbl() const { return *_desc_tbl; }
void set_desc_tbl(const DescriptorTbl* desc_tbl) { _desc_tbl = desc_tbl; }
- MOCK_FUNCTION int batch_size() const { return _query_options.batch_size; }
+
+ // Row-count limit for output blocks (default 65535, range [1, 65535]).
+ // Consistent with SessionVariable.batchSize on FE side.
+ MOCK_FUNCTION int batch_size() const {
+ static constexpr int kDefault = 65535;
+ auto v = _query_options.batch_size;
+ return std::min(std::max(1, v), kDefault);
+ }
+
+ // Target byte budget per output block (default 8MB).
+ // FE validates the range [1MB, 512MB] in SessionVariable; BE trusts that
+ // but applies a default when the field is unset.
+ MOCK_FUNCTION size_t preferred_block_size_bytes() const {
+ static constexpr int64_t kDefault = 8388608L; // 8MB
+ static constexpr int64_t kMax = 536870912L; // 512MB
+ static constexpr int64_t kMin = 1048576L; // 1MB
+ if (_query_options.__isset.preferred_block_size_bytes) [[likely]] {
+ return std::max(kMin,
std::min(_query_options.preferred_block_size_bytes, kMax));
Review Comment:
Blocking: this accessor is now the byte-budget source for a lot of
operator/sort/exchange paths, but it ignores
`config::enable_adaptive_batch_size`. Storage/FileScanner gate on the config,
yet unchanged consumers such as `FullSorter::get_next`,
`ShuffleExchanger::get_block`, `UnionSinkOperatorX`, `ESScanner`, and the
`BlockBudget` users still call `state->preferred_block_size_bytes()` directly.
So `set_be_param('enable_adaptive_batch_size', 'false')` only disables part of
the feature; those paths will continue splitting on bytes. The config needs to
be enforced here or at every caller.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -1294,14 +1297,37 @@ public void checkQuerySlotCount(String slotCnt) {
@VarAttrDef.VarAttr(name = HAVE_QUERY_CACHE, flag = VarAttrDef.READ_ONLY)
public boolean haveQueryCache = false;
- // 4096 minus 16 + 16 bytes padding that in padding pod array
+ // Maximum rows per output block. Default 65535 (the maximum allowed
value).
@VarAttrDef.VarAttr(name = BATCH_SIZE, fuzzy = true, checker =
"checkBatchSize", needForward = true)
- public int batchSize = 8160;
Review Comment:
Blocking: this repurposes the longstanding `batch_size` default into the
adaptive row ceiling instead of introducing the separate
`preferred_block_size_rows` knob described in the PR. `toThrift()` still
forwards `batch_size` as the normal BE row cap, so sessions that never touch
adaptive sizing now default to `65535` rows everywhere, including
fallback/non-adaptive paths (`TabletReader::batch_max_rows()` when the feature
is off, schema scanners, result buffers, sink writers, etc.). That means
`enable_adaptive_batch_size=false` no longer preserves the old fixed-row
behavior; it silently makes fixed batches much larger. This needs a separate
adaptive-only field instead of changing the semantics of the existing
`batch_size` setting.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -6116,6 +6144,30 @@ public void checkAiContextWindowSize(String value)
throws Exception {
checkFieldLongValue(AI_CONTEXT_WINDOW_SIZE, 1, value);
}
+ private static final long PREFERRED_BLOCK_SIZE_BYTES_MIN = 1048576L;
// 1MB
+ private static final long PREFERRED_BLOCK_SIZE_BYTES_MAX = 536870912L;
// 512MB
+
Review Comment:
Blocking: the new user/wire contract says `preferred_block_size_bytes = 0`
disables adaptive sizing (the thrift comments and the PR release note both say
that), but this validator rejects `0`, and BE currently clamps a received `0`
to `1MB` instead of honoring the sentinel. So the documented disable path
cannot work end to end. The same mismatch exists for
`preferred_max_column_in_block_size_bytes` (`0` is documented as 'no per-column
limit', but is rejected/clamped). Either support the sentinel everywhere or
stop advertising it.
##########
be/src/storage/rowset/beta_rowset_reader.cpp:
##########
@@ -95,7 +95,20 @@ Status
BetaRowsetReader::get_segment_iterators(RowsetReaderContext* read_context
RETURN_IF_ERROR(_rowset->load());
// convert RowsetReaderContext to StorageReadOptions
- _read_options.block_row_max = read_context->batch_size;
+ // When adaptive batch size is enabled and the byte budget is active, use
the larger
+ // preferred_block_size_rows so the predictor can grow beyond the legacy
batch_size.
+ if (config::enable_adaptive_batch_size &&
read_context->preferred_block_size_bytes > 0 &&
+ read_context->preferred_block_size_rows > 0) {
+ _read_options.block_row_max =
cast_set<uint32_t>(read_context->preferred_block_size_rows);
+ } else {
+ _read_options.block_row_max = read_context->batch_size;
+ }
+ _read_options.preferred_block_size_bytes =
read_context->preferred_block_size_bytes;
+ _read_options.preferred_block_size_rows =
read_context->preferred_block_size_rows;
+ _read_options.preferred_max_col_bytes =
read_context->preferred_max_col_bytes;
+ if (read_context->origin_return_columns != nullptr) {
+ _read_options.adaptive_batch_output_columns =
*read_context->origin_return_columns;
Review Comment:
Blocking: `AdaptiveBlockSizePredictor::update()` assumes `output_columns[i]`
matches the block column at position `i`, but the blocks coming out of rowset
readers on non-direct AGG/UNIQUE paths are still laid out by
`read_context->return_columns` (expanded key/sequence set), not
`origin_return_columns`. Passing the origin list here mislabels per-column
samples whenever storage adds key/sequence columns before a requested value
column. For example, `SELECT v FROM agg_tbl` will account position 0 (the key
column in the rowset block) as `v`, so the per-column cap can be enforced on
the wrong cid. Either keep this vector aligned with the expanded block shape or
move the predictor update after BlockReader has projected back to the origin
columns.
##########
be/src/exec/scan/file_scanner.cpp:
##########
@@ -482,6 +602,10 @@ Status FileScanner::_get_block_wrapped(RuntimeState*
state, Block* block, bool*
// For query job, simply set _src_block_ptr to block.
size_t read_rows = 0;
RETURN_IF_ERROR(_init_src_block(block));
+
Review Comment:
High: this runs for both load and query scans, but only the load path ever
calls `_update_adaptive_batch_size_before_truncate()` /
`_update_adaptive_batch_size_after_truncate()`.
`_process_src_block_after_read_for_query()` still just truncates and returns,
so `_block_size_predictor` never learns on Parquet/ORC/JNI/CSV/JSON query
scans. Since `predict_next_rows()` clamps the no-history case to
`ADAPTIVE_BATCH_INITIAL_PROBE_ROWS`, those queries can stay pinned at 32 rows
per read for the whole file. That's a significant throughput regression rather
than an adaptive policy.
--
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]