Skip to content

Commit 80f7139

Browse files
committed
feat: add "On SortVerbose;" for extra sort info
Add information to the final sort summaries (per thread and master) including the number of comparisons made, the number of times the small and large buffers were sorted due to their capacities, and the total size of the unsorted, uncomressed generated terms.
1 parent 4ebfb7f commit 80f7139

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

sources/sort.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ void WriteStats(POSITION *plspace, WORD par, WORD checkLogType)
156156
char humanGenTermsText[HUMANSTRLEN] = "";
157157
char humanTermsLeftText[HUMANSTRLEN] = "";
158158
char humanBytesText[HUMANSTRLEN] = "";
159+
char humanUnsortedBytesText[HUMANSTRLEN] = "";
159160
char humanComparisonsText[HUMANSTRLEN] = "";
160161
if ( AC.HumanStatsFlag ) {
161162
HumanString(humanGenTermsText, (float)(S->GenTerms), humanTermsSuffix);
162163
HumanString(humanTermsLeftText, (float)(S->TermsLeft), humanTermsSuffix);
163164
HumanString(humanBytesText, (float)(BASEPOSITION(*plspace)), humanBytesSuffix);
165+
HumanString(humanUnsortedBytesText, (float)(S->verbUnsortedSize), humanBytesSuffix);
164166
HumanString(humanComparisonsText, (float)(S->verbComparisons), humanTermsSuffix);
165167
}
166168

@@ -311,15 +313,18 @@ void WriteStats(POSITION *plspace, WORD par, WORD checkLogType)
311313

312314
if ( par == STATSPOSTSORT ) {
313315
if ( AC.SortVerbose ) {
314-
snprintf(buf, sizeof(buf), "%24s Comparisons =%11ld%s",
315-
"",S->verbComparisons,humanComparisonsText);
316+
snprintf(buf, sizeof(buf), "%24s Unsorted bytes =%11ld%s",
317+
"",S->verbUnsortedSize,humanUnsortedBytesText);
316318
MesPrint("%s", buf);
317319
snprintf(buf, sizeof(buf), "%24s Small Buffer =%5ld,%5ld",
318320
"",S->verbSBsortTerms,S->verbSBsortCap);
319321
MesPrint("%s", buf);
320322
snprintf(buf, sizeof(buf), "%24s Large Buffer =%5ld,%5ld",
321323
"",S->verbLBsortPatches,S->verbLBsortCap);
322324
MesPrint("%s", buf);
325+
snprintf(buf, sizeof(buf), "%24s Comparisons =%11ld%s",
326+
"",S->verbComparisons,humanComparisonsText);
327+
MesPrint("%s", buf);
323328
}
324329
}
325330

@@ -414,6 +419,7 @@ int NewSort(PHEAD0)
414419
S->verbSBsortCap = 0;
415420
S->verbLBsortPatches = 0;
416421
S->verbLBsortCap = 0;
422+
S->verbUnsortedSize = 0;
417423
return(0);
418424
}
419425

@@ -2342,10 +2348,8 @@ WORD Compare1(PHEAD WORD *term1, WORD *term2, WORD level)
23422348
WORD prevorder;
23432349
WORD count = -1, localPoly, polyhit = -1;
23442350

2345-
if ( AR.sLevel == 0 ) {
2346-
// Update SortVerbose counter at ground level only
2347-
S->verbComparisons++;
2348-
}
2351+
// Update SortVerbose counter
2352+
S->verbComparisons++;
23492353

23502354
if ( S->PolyFlag ) {
23512355
/*
@@ -4245,6 +4249,9 @@ int StoreTerm(PHEAD WORD *term)
42454249
POSITION pp;
42464250
LONG lSpace, sSpace, RetCode, over, tover;
42474251

4252+
// Update SortVerbose counters
4253+
S->verbUnsortedSize += *term * sizeof(*term);
4254+
42484255
if ( ( ( AP.PreDebug & DUMPTOSORT ) == DUMPTOSORT ) && AR.sLevel == 0 ) {
42494256
#ifdef WITHPTHREADS
42504257
snprintf((char *)(THRbuf),100,"StoreTerm(%d)",AT.identity);

sources/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ typedef struct sOrT {
11611161
LONG verbSBsortCap;
11621162
LONG verbLBsortPatches;
11631163
LONG verbLBsortCap;
1164+
LONG verbUnsortedSize;
11641165
int MaxPatches; /* Maximum number of patches in large buffer */
11651166
int MaxFpatches; /* Maximum number of patches in one filesort */
11661167
int type; /* Main, function or sub(routine) */

sources/threads.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,6 +4059,7 @@ int MasterMerge(void)
40594059
// The total GenTerms is the sum of the thread GenTerms.
40604060
// The total small/large buffer sort info is the sum of the thread info.
40614061
// The total comparison count is the sum of the thread counts.
4062+
// The total unsorted size is the sum of the total generated terms sizes
40624063
S->GenTerms = 0;
40634064
for ( j = 1; j <= numberofworkers; j++ ) {
40644065
S->GenTerms += AB[j]->T.SS->GenTerms;
@@ -4067,6 +4068,7 @@ int MasterMerge(void)
40674068
S->verbSBsortCap += AB[j]->T.SS->verbSBsortCap;
40684069
S->verbLBsortPatches += AB[j]->T.SS->verbLBsortPatches;
40694070
S->verbLBsortCap += AB[j]->T.SS->verbLBsortCap;
4071+
S->verbUnsortedSize += AB[j]->T.SS->verbUnsortedSize;
40704072
}
40714073

40724074
WriteStats(&position,STATSPOSTSORT,NOCHECKLOGTYPE);
@@ -4211,6 +4213,7 @@ int SortBotMasterMerge(void)
42114213
// The total GenTerms is the sum of the thread GenTerms.
42124214
// The total small/large buffer sort info is the sum of the thread info.
42134215
// The total comparison count is the sum of the thread and sortbot counts.
4216+
// The total unsorted size is the sum of the total generated terms sizes
42144217
S->GenTerms = 0;
42154218
for ( j = 1; j <= numberofworkers; j++ ) {
42164219
S->GenTerms += AB[j]->T.SS->GenTerms;
@@ -4219,6 +4222,7 @@ int SortBotMasterMerge(void)
42194222
S->verbSBsortCap += AB[j]->T.SS->verbSBsortCap;
42204223
S->verbLBsortPatches += AB[j]->T.SS->verbLBsortPatches;
42214224
S->verbLBsortCap += AB[j]->T.SS->verbLBsortCap;
4225+
S->verbUnsortedSize += AB[j]->T.SS->verbUnsortedSize;
42224226
}
42234227
for ( j = numberofworkers+1; j <= numberofworkers+numberofsortbots; j++ ) {
42244228
S->verbComparisons += AB[j]->T.SS->verbComparisons;

0 commit comments

Comments
 (0)