Skip to content

Commit

Permalink
HPCC-29885 Default thor to use merge rather than stable quicksort
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Aug 16, 2023
1 parent 651fcfa commit 6a26a96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
11 changes: 0 additions & 11 deletions common/thorhelper/thorsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,9 @@
#include "thorhelper.hpp"
#include "jsort.hpp"

//#define DEFAULT_MERGE_SORT

extern THORHELPER_API void msortvecstableinplace(void ** rows, size_t n, const ICompare & compare, void ** temp);
extern THORHELPER_API void parmsortvecstableinplace(void ** rows, size_t n, const ICompare & compare, void ** temp);

inline void parsortvecstableinplace(void ** rows, size_t n, const ICompare & compare, void ** stableTablePtr, unsigned maxCores=0)
{
#ifdef DEFAULT_MERGE_SORT
parmsortvecstableinplace(rows, n, compare, stableTablePtr);
#else
parqsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
#endif
}

extern THORHELPER_API void tbbqsortvec(void **a, size_t n, const ICompare & compare);
extern THORHELPER_API void tbbqsortstable(void ** rows, size_t n, const ICompare & compare, void ** temp);

Expand Down
11 changes: 10 additions & 1 deletion thorlcr/thorutil/thmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,10 @@ void CThorExpandingRowArray::doSort(rowidx_t n, void **const rows, ICompare &com
dbgassertex(NULL != stableTable);
stableTablePtr = stableTable;
}
parsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
if (useMergeSort)
parmsortvecstableinplace(rows, n, compare, stableTablePtr);
else
parqsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
}
else
parqsortvec((void **)rows, n, compare, maxCores);
Expand Down Expand Up @@ -720,6 +723,12 @@ void CThorExpandingRowArray::setup(IThorRowInterfaces *_rowIf, EmptyRowSemantics
ReleaseThorRow(stableTable);
stableTable = NULL;
}
if (stableSort_none != stableSort)
{
StringBuffer algorithm;
activity.getOpt(THOROPT_SORT_ALGORITHM, algorithm);
useMergeSort = !strieq(algorithm, "quicksort");
}
}

void CThorExpandingRowArray::clearRows()
Expand Down
1 change: 1 addition & 0 deletions thorlcr/thorutil/thmem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class graph_decl CThorExpandingRowArray : public CSimpleInterface
const void **rows = nullptr;
void **stableTable = nullptr;
bool throwOnOom = true; // tested during array expansion (resize())
bool useMergeSort = true;
EmptyRowSemantics emptyRowSemantics = ers_forbidden;
StableSortFlag stableSort = stableSort_none;
rowidx_t maxRows = 0; // Number of rows that can fit in the allocated memory.
Expand Down
1 change: 1 addition & 0 deletions thorlcr/thorutil/thormisc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#define THOROPT_MEMORY_SPILL_AT "memorySpillAt" // The threshold (%) that roxiemem will request memory to be reduced (default=80)
#define THOROPT_FAIL_ON_LEAKS "failOnLeaks" // If any leaks are detected at the end of graph, fail the query (default=false)
#define THOROPT_SOAP_TRACE_LEVEL "soapTraceLevel" // The trace SOAP level (default=1)
#define THOROPT_SORT_ALGORITHM "sortAlgorithm" // The algorithm used to sort records (quicksort/mergesort)


#define INITIAL_SELFJOIN_MATCH_WARNING_LEVEL 20000 // max of row matches before selfjoin emits warning
Expand Down

0 comments on commit 6a26a96

Please sign in to comment.