1414use std:: {
1515 collections:: { HashMap , HashSet } ,
1616 pin:: pin,
17+ time:: Instant ,
1718} ;
1819
1920use chrono:: { DateTime , Utc } ;
@@ -23,7 +24,7 @@ use mas_storage::Clock;
2324use rand:: RngCore ;
2425use thiserror:: Error ;
2526use thiserror_ext:: ContextInto ;
26- use tracing:: { Level , Span } ;
27+ use tracing:: { info , Level , Span } ;
2728use tracing_indicatif:: { span_ext:: IndicatifSpanExt , style:: ProgressStyle } ;
2829use ulid:: Ulid ;
2930use uuid:: Uuid ;
@@ -246,6 +247,8 @@ async fn migrate_users(
246247 server_name : & str ,
247248 rng : & mut impl RngCore ,
248249) -> Result < UsersMigrated , Error > {
250+ let start = Instant :: now ( ) ;
251+
249252 let span = Span :: current ( ) ;
250253 span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
251254 span. pb_set_length ( user_count_hint as u64 ) ;
@@ -292,6 +295,11 @@ async fn migrate_users(
292295 . await
293296 . into_mas ( "writing passwords" ) ?;
294297
298+ info ! (
299+ "users migrated in {:.1}s" ,
300+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
301+ ) ;
302+
295303 Ok ( UsersMigrated {
296304 user_localparts_to_uuid,
297305 synapse_admins,
@@ -307,6 +315,8 @@ async fn migrate_threepids(
307315 rng : & mut impl RngCore ,
308316 user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
309317) -> Result < ( ) , Error > {
318+ let start = Instant :: now ( ) ;
319+
310320 let span = Span :: current ( ) ;
311321 span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
312322 span. pb_set_length ( count_hint) ;
@@ -386,6 +396,11 @@ async fn migrate_threepids(
386396 . await
387397 . into_mas ( "writing unsupported threepids" ) ?;
388398
399+ info ! (
400+ "third-party IDs migrated in {:.1}s" ,
401+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
402+ ) ;
403+
389404 Ok ( ( ) )
390405}
391406
@@ -403,6 +418,8 @@ async fn migrate_external_ids(
403418 user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
404419 provider_id_mapping : & HashMap < String , Uuid > ,
405420) -> Result < ( ) , Error > {
421+ let start = Instant :: now ( ) ;
422+
406423 let span = Span :: current ( ) ;
407424 span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
408425 span. pb_set_length ( count_hint) ;
@@ -464,7 +481,12 @@ async fn migrate_external_ids(
464481 write_buffer
465482 . finish ( mas)
466483 . await
467- . into_mas ( "writing threepids" ) ?;
484+ . into_mas ( "writing upstream links" ) ?;
485+
486+ info ! (
487+ "upstream links (external IDs) migrated in {:.1}s" ,
488+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
489+ ) ;
468490
469491 Ok ( ( ) )
470492}
@@ -489,6 +511,8 @@ async fn migrate_devices(
489511 devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
490512 synapse_admins : & HashSet < Uuid > ,
491513) -> Result < ( ) , Error > {
514+ let start = Instant :: now ( ) ;
515+
492516 let span = Span :: current ( ) ;
493517 span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
494518 span. pb_set_length ( count_hint) ;
@@ -573,6 +597,11 @@ async fn migrate_devices(
573597 . await
574598 . into_mas ( "writing compat sessions" ) ?;
575599
600+ info ! (
601+ "devices migrated in {:.1}s" ,
602+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
603+ ) ;
604+
576605 Ok ( ( ) )
577606}
578607
@@ -590,6 +619,8 @@ async fn migrate_unrefreshable_access_tokens(
590619 user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
591620 devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
592621) -> Result < ( ) , Error > {
622+ let start = Instant :: now ( ) ;
623+
593624 let span = Span :: current ( ) ;
594625 span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
595626 span. pb_set_length ( count_hint) ;
@@ -691,6 +722,11 @@ async fn migrate_unrefreshable_access_tokens(
691722 . await
692723 . into_mas ( "writing deviceless compat sessions" ) ?;
693724
725+ info ! (
726+ "non-refreshable access tokens migrated in {:.1}s" ,
727+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
728+ ) ;
729+
694730 Ok ( ( ) )
695731}
696732
@@ -708,6 +744,8 @@ async fn migrate_refreshable_token_pairs(
708744 user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
709745 devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
710746) -> Result < ( ) , Error > {
747+ let start = Instant :: now ( ) ;
748+
711749 let span = Span :: current ( ) ;
712750 span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
713751 span. pb_set_length ( count_hint) ;
@@ -797,6 +835,11 @@ async fn migrate_refreshable_token_pairs(
797835 . await
798836 . into_mas ( "writing compat refresh tokens" ) ?;
799837
838+ info ! (
839+ "refreshable token pairs migrated in {:.1}s" ,
840+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
841+ ) ;
842+
800843 Ok ( ( ) )
801844}
802845
0 commit comments