@@ -123,6 +123,10 @@ pub(crate) struct Queue<B: BatchType> {
123
123
/// Id of the next batch
124
124
next_batch_id : u64 ,
125
125
126
+ // Keep track what was logged in the last call to try_next_batch
127
+ // so as to avoid many repeating entries in the log
128
+ last_logged : Option < ( usize , usize ) > ,
129
+
126
130
/// Just a constant empty map to reuse
127
131
empty_map : IntMap < u64 , Entry > ,
128
132
}
@@ -138,6 +142,7 @@ impl<B: BatchType> Queue<B> {
138
142
next_id : 0 ,
139
143
next_batch_id : 1 ,
140
144
batch_type : PhantomData ,
145
+ last_logged : None ,
141
146
empty_map : IntMap :: default ( ) ,
142
147
}
143
148
}
@@ -215,12 +220,14 @@ impl<B: BatchType> Queue<B> {
215
220
let buffer_size = self . buffer . len ( ) ;
216
221
if buffer_size < min_size {
217
222
// Not enough requests waiting to reach min_size
223
+ self . last_logged = None ;
218
224
return None
219
225
}
220
226
221
227
let mut total_count = entries. len ( ) ;
222
228
if total_count + min_size > self . config . size_limit {
223
229
// Not enough space to fit min_size within max batch size
230
+ self . last_logged = None ;
224
231
return None
225
232
}
226
233
@@ -290,6 +297,7 @@ impl<B: BatchType> Queue<B> {
290
297
if <B >:: exceeds_weight ( tree, config. weight_limit , output_len) {
291
298
if chosen_indices. len ( ) + buffer_size < min_size + index + 1 {
292
299
// We don't have enough remaining to meet min_size
300
+ self . last_logged = None ;
293
301
return None
294
302
}
295
303
// Remove our tuple from the set
@@ -337,12 +345,21 @@ impl<B: BatchType> Queue<B> {
337
345
}
338
346
339
347
let chosen_count = chosen_indices. len ( ) ;
340
- info ! ( "Chose {chosen_count} out of {buffer_size} requests from buffer, \
341
- total now {total_count}") ;
342
348
if chosen_count == 0 {
349
+ // Don't repeatedly log when no requests were chosen if the current/waiting
350
+ // request counts haven't changed
351
+ let current_counts = Some ( ( buffer_size, total_count) ) ;
352
+ if self . last_logged != current_counts {
353
+ self . last_logged = current_counts;
354
+ info ! ( "Chose 0 out of {buffer_size} requests from buffer, total now {total_count}" ) ;
355
+ }
343
356
return None
344
357
}
345
358
359
+ self . last_logged = None ;
360
+ info ! ( "Chose {chosen_count} out of {buffer_size} requests from buffer, \
361
+ total now {total_count}") ;
362
+
346
363
let some_now = Some ( now) ;
347
364
let requests = chosen_indices. iter ( ) . enumerate ( ) . map ( |( i, index) | {
348
365
let mut entry = self . buffer . remove ( index - i) . expect ( "bug" ) ;
0 commit comments