github-actions[bot] commented on code in PR #68610:
URL: https://github.com/apache/doris/pull/68610#discussion_r4132871043


##########
be/src/exec/scan/scanner.cpp:
##########
@@ -88,6 +89,38 @@ Status Scanner::init(RuntimeState* state, const 
VExprContextSPtrs& conjuncts) {
 }
 
 Status Scanner::get_block_after_projects(RuntimeState* state, Block* block, 
bool* eos) {
+    RETURN_IF_ERROR(_get_block_after_projects(state, block, eos));
+    // Publish progress to the shared counter so peer scanners can observe it. 
Only rows that leave
+    // the scanner are charged: rows still held in _padding_block are not 
charged, because once
+    // the counter is exhausted the context may finish without running this 
scanner again. The
+    // counter may go negative when several scanners subtract concurrently; 
that is harmless
+    // because the operator's reached_limit() makes the final cut.
+    if (_shared_scan_limit && block->rows() > 0) {
+        _shared_scan_limit->fetch_sub(block->rows(), 
std::memory_order_acq_rel);
+        *eos = *eos || _shared_scan_limit->load(std::memory_order_acquire) <= 
0;
+    }
+    // After the charge above, so peers never see the emitted rows missing 
from both counters.
+    _publish_padding_rows();
+    return Status::OK();
+}
+
+void Scanner::_publish_padding_rows() {
+    if (!_shared_scan_limit) {
+        return;
+    }
+    const auto padding_rows = cast_set<int64_t>(_padding_block.rows());
+    _shared_scan_buffered_rows->fetch_add(padding_rows - 
_published_padding_rows,

Review Comment:
   [P2] Skip zero-delta publication on ordinary LIMIT scans. 
`get_block_after_projects()` calls this for every successful block, but the 
no-projection path leaves `_padding_block` and `_published_padding_rows` at 
zero. `fetch_add(0, acq_rel)` still adds a shared atomic read-modify-write on 
every block across parallel scanners, with no value to publish. Skip the RMW 
when the padding-row delta is zero, while retaining updates when padding 
actually changes.



-- 
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]

Reply via email to