@@ -240,7 +240,7 @@ OUTB:
240240
241241// Boolean returned indicates whether this generation has any tasks.
242242func (verifier * Verifier ) printNamespaceStatistics (ctx context.Context , strBuilder * strings.Builder , now time.Time ) (bool , error ) {
243- stats , err := verifier .GetNamespaceStatistics (ctx )
243+ stats , err := verifier .GetPersistedNamespaceStatistics (ctx )
244244 if err != nil {
245245 return false , err
246246 }
@@ -282,6 +282,25 @@ func (verifier *Verifier) printNamespaceStatistics(ctx context.Context, strBuild
282282
283283 elapsed := now .Sub (verifier .generationStartTime )
284284
285+ var activeWorkers int
286+ perNamespaceWorkerStats := verifier .getPerNamespaceWorkerStats ()
287+ for _ , nsWorkerStats := range perNamespaceWorkerStats {
288+ for _ , workerStats := range nsWorkerStats {
289+ activeWorkers ++
290+ comparedDocs += workerStats .SrcDocCount
291+ comparedBytes += workerStats .SrcByteCount
292+ }
293+ }
294+
295+ if activeWorkers > 0 {
296+ fmt .Fprintf (
297+ strBuilder ,
298+ "Active document comparison threads: %d of %d\n " ,
299+ activeWorkers ,
300+ verifier .numWorkers ,
301+ )
302+ }
303+
285304 docsPerSecond := float64 (comparedDocs ) / elapsed .Seconds ()
286305 bytesPerSecond := float64 (comparedBytes ) / elapsed .Seconds ()
287306 perSecondDataUnit := reportutils .FindBestUnit (bytesPerSecond )
@@ -336,7 +355,7 @@ func (verifier *Verifier) printNamespaceStatistics(ctx context.Context, strBuild
336355
337356 table := tablewriter .NewWriter (strBuilder )
338357
339- headers := []string {"Src Namespace" , "Src Docs Compared" }
358+ headers := []string {"Src Namespace" , "Threads" , " Src Docs Compared" }
340359 if showDataTotals {
341360 headers = append (headers , "Src Data Compared" )
342361 }
@@ -351,18 +370,32 @@ func (verifier *Verifier) printNamespaceStatistics(ctx context.Context, strBuild
351370
352371 tableHasRows = true
353372
354- row := []string {result .Namespace }
373+ var threads int
374+
375+ docsCompared := result .DocsCompared
376+ bytesCompared := result .BytesCompared
377+
378+ if nsWorkerStats , ok := perNamespaceWorkerStats [result .Namespace ]; ok {
379+ threads = len (nsWorkerStats )
380+
381+ for _ , workerStats := range nsWorkerStats {
382+ docsCompared += workerStats .SrcDocCount
383+ bytesCompared += workerStats .SrcByteCount
384+ }
385+ }
386+
387+ row := []string {result .Namespace , reportutils .FmtReal (threads )}
355388
356389 var docsCell string
357390
358391 if result .TotalDocs > 0 {
359392 docsCell = fmt .Sprintf ("%s of %s (%s%%)" ,
360- reportutils .FmtReal (result . DocsCompared ),
393+ reportutils .FmtReal (docsCompared ),
361394 reportutils .FmtReal (result .TotalDocs ),
362- reportutils .FmtPercent (result . DocsCompared , result .TotalDocs ),
395+ reportutils .FmtPercent (docsCompared , result .TotalDocs ),
363396 )
364397 } else {
365- docsCell = reportutils .FmtReal (result . DocsCompared )
398+ docsCell = reportutils .FmtReal (docsCompared )
366399 }
367400
368401 row = append (row , docsCell )
@@ -374,16 +407,16 @@ func (verifier *Verifier) printNamespaceStatistics(ctx context.Context, strBuild
374407 dataUnit := reportutils .FindBestUnit (result .TotalBytes )
375408
376409 dataCell = fmt .Sprintf ("%s of %s %s (%s%%)" ,
377- reportutils .BytesToUnit (result . BytesCompared , dataUnit ),
410+ reportutils .BytesToUnit (bytesCompared , dataUnit ),
378411 reportutils .BytesToUnit (result .TotalBytes , dataUnit ),
379412 dataUnit ,
380- reportutils .FmtPercent (result . BytesCompared , result .TotalBytes ),
413+ reportutils .FmtPercent (bytesCompared , result .TotalBytes ),
381414 )
382415 } else {
383- dataUnit := reportutils .FindBestUnit (result . BytesCompared )
416+ dataUnit := reportutils .FindBestUnit (bytesCompared )
384417
385418 dataCell = fmt .Sprintf ("%s %s" ,
386- reportutils .BytesToUnit (result . BytesCompared , dataUnit ),
419+ reportutils .BytesToUnit (bytesCompared , dataUnit ),
387420 dataUnit ,
388421 )
389422 }
@@ -403,7 +436,7 @@ func (verifier *Verifier) printNamespaceStatistics(ctx context.Context, strBuild
403436}
404437
405438func (verifier * Verifier ) printEndOfGenerationStatistics (ctx context.Context , strBuilder * strings.Builder , now time.Time ) (bool , error ) {
406- stats , err := verifier .GetNamespaceStatistics (ctx )
439+ stats , err := verifier .GetPersistedNamespaceStatistics (ctx )
407440 if err != nil {
408441 return false , err
409442 }
@@ -564,6 +597,25 @@ func (verifier *Verifier) printChangeEventStatistics(builder *strings.Builder, n
564597 }
565598}
566599
600+ func (verifier * Verifier ) getPerNamespaceWorkerStats () map [string ][]WorkerStatus {
601+ wsmap := verifier .workerTracker .Load ()
602+
603+ retMap := map [string ][]WorkerStatus {}
604+
605+ for _ , workerStats := range wsmap {
606+ if workerStats .TaskID == nil {
607+ continue
608+ }
609+
610+ retMap [workerStats .Namespace ] = append (
611+ retMap [workerStats .Namespace ],
612+ workerStats ,
613+ )
614+ }
615+
616+ return retMap
617+ }
618+
567619func (verifier * Verifier ) printWorkerStatus (builder * strings.Builder , now time.Time ) {
568620
569621 table := tablewriter .NewWriter (builder )
@@ -572,7 +624,7 @@ func (verifier *Verifier) printWorkerStatus(builder *strings.Builder, now time.T
572624 wsmap := verifier .workerTracker .Load ()
573625
574626 activeThreadCount := 0
575- for w := 0 ; w <= verifier .numWorkers ; w ++ {
627+ for w := range verifier .numWorkers {
576628 if wsmap [w ].TaskID == nil {
577629 continue
578630 }
@@ -590,23 +642,27 @@ func (verifier *Verifier) printWorkerStatus(builder *strings.Builder, now time.T
590642 taskIdStr = fmt .Sprintf ("%s" , wsmap [w ].TaskID )
591643 }
592644
645+ var detail string
646+ if wsmap [w ].TaskType == verificationTaskVerifyDocuments {
647+ detail = fmt .Sprintf (
648+ "%s documents (%s)" ,
649+ reportutils .FmtReal (wsmap [w ].SrcDocCount ),
650+ reportutils .FmtBytes (wsmap [w ].SrcByteCount ),
651+ )
652+ }
653+
593654 table .Append (
594655 []string {
595656 reportutils .FmtReal (w ),
596657 wsmap [w ].Namespace ,
597658 taskIdStr ,
598659 reportutils .DurationToHMS (now .Sub (wsmap [w ].StartTime )),
599- wsmap [ w ]. Detail ,
660+ detail ,
600661 },
601662 )
602663 }
603664
604- fmt .Fprintf (
605- builder ,
606- "\n Active worker threads (%s of %s):\n " ,
607- reportutils .FmtReal (activeThreadCount ),
608- reportutils .FmtReal (verifier .numWorkers ),
609- )
665+ fmt .Fprintf (builder , "\n Worker thread details:\n " )
610666
611667 table .Render ()
612668}
0 commit comments