@@ -27,15 +27,18 @@ use common::{
2727 errors:: report_error,
2828 knobs:: {
2929 SUBSCRIPTIONS_WORKER_QUEUE_SIZE ,
30+ SUBSCRIPTION_ADVANCE_LOG_TRACING_THRESHOLD ,
3031 SUBSCRIPTION_INVALIDATION_DELAY_MULTIPLIER ,
3132 SUBSCRIPTION_INVALIDATION_DELAY_THRESHOLD ,
33+ SUBSCRIPTION_PROCESS_LOG_ENTRY_TRACING_THRESHOLD ,
3234 } ,
3335 runtime:: {
3436 block_in_place,
3537 Runtime ,
3638 SpawnHandle ,
3739 } ,
3840 types:: {
41+ GenericIndexName ,
3942 PersistenceVersion ,
4043 SubscriberId ,
4144 TabletIndexName ,
@@ -328,9 +331,12 @@ impl SubscriptionManager {
328331 let mut log_len = 0 ;
329332 let mut num_writes = 0 ;
330333 self . log . for_each ( from_ts, next_ts, |_, writes| {
334+ let process_log_timer = metrics:: subscription_process_write_log_entry_timer ( ) ;
331335 log_len += 1 ;
332336 num_writes += writes. len ( ) ;
333- for ( _, document_change) in writes {
337+ let mut tablet_ids = BTreeSet :: new ( ) ;
338+ for ( resolved_id, document_change) in writes {
339+ tablet_ids. insert ( resolved_id. tablet_id ) ;
334340 // We're applying a mutation to the document so if it already exists
335341 // we need to remove it before writing the new version.
336342 if let Some ( ref old_document) = document_change. old_document {
@@ -352,9 +358,46 @@ impl SubscriptionManager {
352358 ) ;
353359 }
354360 }
361+
362+ if process_log_timer. elapsed ( )
363+ > Duration :: from_secs ( * SUBSCRIPTION_PROCESS_LOG_ENTRY_TRACING_THRESHOLD )
364+ {
365+ tracing:: info!(
366+ "[{next_ts}: advance_log] simple commit took {:?}, affected tables: \
367+ {tablet_ids:?}",
368+ process_log_timer. elapsed( )
369+ ) ;
370+ }
355371 } ) ?;
356372 metrics:: log_subscriptions_log_length ( log_len) ;
357373 metrics:: log_subscriptions_log_writes ( num_writes) ;
374+ if _timer. elapsed ( )
375+ > Duration :: from_secs ( * SUBSCRIPTION_ADVANCE_LOG_TRACING_THRESHOLD )
376+ {
377+ let subscribers_by_index: BTreeMap < & GenericIndexName < _ > , usize > = self
378+ . subscriptions
379+ . indexed
380+ . iter ( )
381+ . map ( |( key, ( _fields, range_map) ) | ( key, range_map. len ( ) ) )
382+ . collect ( ) ;
383+ let total_subscribers: usize = subscribers_by_index. values ( ) . sum ( ) ;
384+ let search_len = self . subscriptions . search . filter_len ( ) ;
385+ let fuzzy_len = self . subscriptions . search . fuzzy_len ( ) ;
386+ tracing:: info!(
387+ "[{next_ts} advance_log] Duration {}ms, indexes: {}, search filters: {}, \
388+ fuzzy search: {}",
389+ _timer. elapsed( ) . as_millis( ) ,
390+ self . subscriptions. indexed. len( ) ,
391+ search_len,
392+ fuzzy_len
393+ ) ;
394+ tracing:: info!(
395+ "`[{next_ts} advance_log] Subscription map size: {total_subscribers}"
396+ ) ;
397+ tracing:: info!(
398+ "[{next_ts} advance_log] Subscribers by index {subscribers_by_index:?}"
399+ ) ;
400+ }
358401 }
359402
360403 {
0 commit comments