@@ -346,9 +346,6 @@ impl<C: CursorValues> SortPreservingMergeStream<C> {
346346 // The batch is fully emitted: retire the cursor like `advance_cursors` does for a finished one
347347 self . prev_cursors [ stream_idx] = self . cursors [ stream_idx] . take ( ) ;
348348 self . loser_tree_adjusted = false ;
349- if self . enable_round_robin_tie_breaker {
350- self . update_poll_count_after_skip ( stream_idx) ;
351- }
352349
353350 if self . in_progress . is_empty ( ) {
354351 self . produced += batch. num_rows ( ) ;
@@ -398,15 +395,13 @@ impl<C: CursorValues> SortPreservingMergeStream<C> {
398395 if let Some ( other) = & self . cursors [ challenger] {
399396 let beats = match winner_cursor. compare_last_to ( other) {
400397 Ordering :: Less => true ,
401- // Mirror the loser tree's tie-breaking: round-robin by
402- // poll count when enabled (see [`Self::handle_tie`]) so
403- // batch-level ties alternate between streams instead of
404- // starving one, otherwise by stream index like
405- // [`Self::is_gt`]
406398 Ordering :: Equal => {
407399 if self . enable_round_robin_tie_breaker {
408- !self . is_skip_poll_count_gt ( winner, challenger)
400+ // true if in round-robin because the winner already decided in a
401+ // round-robin fashion
402+ true
409403 } else {
404+ // Keep sort stable
410405 winner < challenger
411406 }
412407 }
@@ -485,38 +480,6 @@ impl<C: CursorValues> SortPreservingMergeStream<C> {
485480 poll_a. cmp ( & poll_b) . then_with ( || a. cmp ( & b) ) . is_gt ( )
486481 }
487482
488- /// Poll count of `idx`, treating counts from a stale reset epoch as zero
489- /// (the same lazy reset [`Self::update_poll_count_on_the_same_value`] does)
490- #[ inline]
491- fn effective_poll_count ( & self , idx : usize ) -> usize {
492- if self . poll_reset_epochs [ idx] == self . current_reset_epoch {
493- self . num_of_polled_with_same_value [ idx]
494- } else {
495- 0
496- }
497- }
498-
499- /// Like [`Self::is_poll_count_gt`], but epoch-aware since full-batch skips
500- /// happen outside the per-row tie-breaker flow that lazily resets counts
501- #[ inline]
502- fn is_skip_poll_count_gt ( & self , a : usize , b : usize ) -> bool {
503- self . effective_poll_count ( a)
504- . cmp ( & self . effective_poll_count ( b) )
505- . then_with ( || a. cmp ( & b) )
506- . is_gt ( )
507- }
508-
509- /// Count a full-batch skip as a poll so consecutive batch-level ties
510- /// round-robin between the streams instead of starving one
511- #[ inline]
512- fn update_poll_count_after_skip ( & mut self , idx : usize ) {
513- if self . poll_reset_epochs [ idx] != self . current_reset_epoch {
514- self . poll_reset_epochs [ idx] = self . current_reset_epoch ;
515- self . num_of_polled_with_same_value [ idx] = 0 ;
516- }
517- self . num_of_polled_with_same_value [ idx] += 1 ;
518- }
519-
520483 #[ inline]
521484 fn update_winner ( & mut self , cmp_node : usize , winner : & mut usize , challenger : usize ) {
522485 self . loser_tree [ cmp_node] = * winner;
0 commit comments