|
| 1 | +#include <ydb/core/kqp/tools/combiner_perf/printout.h> |
1 | 2 | #include <ydb/core/kqp/tools/combiner_perf/simple_last.h>
|
2 | 3 | #include <ydb/core/kqp/tools/combiner_perf/simple.h>
|
3 | 4 | #include <ydb/core/kqp/tools/combiner_perf/tpch_last.h>
|
|
7 | 8 |
|
8 | 9 | #include <util/stream/output.h>
|
9 | 10 | #include <util/stream/file.h>
|
| 11 | +#include <util/string/printf.h> |
10 | 12 | #include <util/system/compiler.h>
|
11 | 13 |
|
12 |
| -void DoFullPass(bool withSpilling) |
| 14 | +using NKikimr::NMiniKQL::TRunParams; |
| 15 | + |
| 16 | +class TPrintingResultCollector : public TTestResultCollector |
13 | 17 | {
|
14 |
| - using namespace NKikimr::NMiniKQL; |
| 18 | +public: |
| 19 | + virtual void SubmitTestNameAndParams(const TRunParams& runParams, const char* testName, const std::optional<bool> llvm, const std::optional<bool> spilling) override |
| 20 | + { |
| 21 | + Cout << "------------------------------" << Endl; |
| 22 | + Cout << testName; |
| 23 | + if (llvm.has_value()) { |
| 24 | + Cout << ", " << (llvm.value() ? "+" : "-") << "llvm"; |
| 25 | + } |
| 26 | + if (spilling.has_value()) { |
| 27 | + Cout << ", " << (spilling.value() ? "+" : "-") << "spilling"; |
| 28 | + } |
| 29 | + Cout << Endl; |
| 30 | + Cout << "Data rows total: " << runParams.RowsPerRun << " x " << runParams.NumRuns << Endl; |
| 31 | + Cout << (runParams.MaxKey + 1) << " distinct numeric keys" << Endl; |
| 32 | + Cout << "Block size: " << runParams.BlockSize << Endl; |
| 33 | + Cout << "Long strings: " << (runParams.LongStringKeys ? "yes" : "no") << Endl; |
| 34 | + Cout << Endl; |
| 35 | + } |
15 | 36 |
|
16 |
| - TRunParams runParams; |
| 37 | + virtual void SubmitTimings(const TDuration& graphTime, const TDuration& referenceTime, const std::optional<TDuration> streamTime) override |
| 38 | + { |
| 39 | + Cout << "Graph runtime is: " << graphTime << " vs. reference C++ implementation: " << referenceTime << Endl; |
17 | 40 |
|
18 |
| - runParams.NumRuns = 20; |
19 |
| - runParams.RowsPerRun = 5'000'000; |
20 |
| - runParams.MaxKey = 200'000 - 1; |
21 |
| - runParams.BlockSize = 5'000; |
22 |
| - runParams.LongStringKeys = true; |
| 41 | + if (streamTime.has_value()) { |
| 42 | + Cout << "Input stream own iteration time: " << *streamTime << Endl; |
| 43 | + Cout << "Graph time - stream own time = " << (*streamTime <= graphTime ? graphTime - *streamTime : TDuration::Zero()) << Endl; |
| 44 | + Cout << "C++ implementation time - devnull time = " << (*streamTime <= referenceTime ? referenceTime - *streamTime : TDuration::Zero()) << Endl; |
| 45 | + } |
| 46 | + } |
| 47 | +}; |
23 | 48 |
|
24 |
| - RunTestBlockCombineHashedSimple<false, false>(runParams); |
| 49 | +class TWikiResultCollector : public TTestResultCollector |
| 50 | +{ |
| 51 | +public: |
| 52 | + TWikiResultCollector() |
| 53 | + { |
| 54 | + Cout << "#|" << Endl; |
| 55 | + Cout << "|| Test name | LLVM | Spilling | RowsTotal | Distinct keys | Block size | Input stream own time (s) | Graph time - stream time (s) | C++ time - stream time (s) | Shame ratio ||" << Endl; |
| 56 | + } |
25 | 57 |
|
26 |
| - auto doSimpleLast = [](const TRunParams& params) { |
27 |
| - Cerr << "LastSimple, -llvm, -spilling" << Endl; |
28 |
| - NKikimr::NMiniKQL::RunTestCombineLastSimple<false, false>(params); |
| 58 | + ~TWikiResultCollector() |
| 59 | + { |
| 60 | + Cout << "|#" << Endl; |
| 61 | + } |
29 | 62 |
|
30 |
| - if (false) { |
31 |
| - Cerr << "LastSimple, +llvm, -spilling" << Endl; |
32 |
| - NKikimr::NMiniKQL::RunTestCombineLastSimple<true, false>(params); |
| 63 | + virtual void SubmitTestNameAndParams(const TRunParams& runParams, const char* testName, const std::optional<bool> llvm, const std::optional<bool> spilling) override |
| 64 | + { |
| 65 | + Cout << "|| "; |
| 66 | + Cout << testName << " | "; |
| 67 | + if (llvm.has_value()) { |
| 68 | + Cout << (llvm.value() ? "+" : " "); |
33 | 69 | }
|
34 |
| - }; |
| 70 | + Cout << " | "; |
| 71 | + if (spilling.has_value()) { |
| 72 | + Cout << (spilling.value() ? "+" : " "); |
| 73 | + } |
| 74 | + Cout << " | "; |
35 | 75 |
|
36 |
| - doSimpleLast(runParams); |
| 76 | + Cout << (runParams.RowsPerRun * runParams.NumRuns) << " | " << (runParams.MaxKey + 1) << " | "; |
| 77 | + if (TStringBuf(testName).Contains("Block")) { |
| 78 | + Cout << runParams.BlockSize; |
| 79 | + } |
| 80 | + Cout << " | "; |
| 81 | + } |
37 | 82 |
|
38 |
| - if (false) { |
39 |
| - Cerr << "Simple, -llvm, -spilling" << Endl; |
40 |
| - NKikimr::NMiniKQL::RunTestSimple<false>(); |
| 83 | + static TString FancyDuration(const TDuration duration) |
| 84 | + { |
| 85 | + const auto ms = duration.MilliSeconds(); |
| 86 | + if (!ms) { |
| 87 | + return " "; |
| 88 | + } |
| 89 | + return Sprintf("%.2f", (ms / 1000.0)); |
| 90 | + } |
41 | 91 |
|
42 |
| - Cerr << "Simple, +llvm, -spilling" << Endl; |
43 |
| - NKikimr::NMiniKQL::RunTestSimple<true>(); |
| 92 | + virtual void SubmitTimings(const TDuration& graphTime, const TDuration& referenceTime, const std::optional<TDuration> streamTime) override |
| 93 | + { |
| 94 | + TDuration streamTimeOrZero = (streamTime.has_value()) ? streamTime.value() : TDuration::Zero(); |
| 95 | + TDuration corrGraphTime = streamTimeOrZero <= graphTime ? graphTime - streamTimeOrZero : TDuration::Zero(); |
| 96 | + TDuration corrRefTime = streamTimeOrZero <= referenceTime ? referenceTime - streamTimeOrZero : TDuration::Zero(); |
44 | 97 |
|
45 |
| - Cerr << "LastTpch, -llvm, -spilling" << Endl; |
46 |
| - NKikimr::NMiniKQL::RunTestLastTpch<false, false>(); |
| 98 | + TString diff; |
| 99 | + if (corrRefTime.MilliSeconds() > 0) { |
| 100 | + diff = Sprintf("%.2f", corrGraphTime.MilliSeconds() * 1.0 / corrRefTime.MilliSeconds()); |
| 101 | + } |
47 | 102 |
|
48 |
| - Cerr << "LastTpch, +llvm, -spilling" << Endl; |
49 |
| - NKikimr::NMiniKQL::RunTestLastTpch<true, false>(); |
| 103 | + Cout << FancyDuration(streamTimeOrZero) << " | " << FancyDuration(corrGraphTime) << " | " << FancyDuration(corrRefTime) << " | " << diff << " ||" << Endl; |
| 104 | + Cout.Flush(); |
50 | 105 | }
|
| 106 | +}; |
51 | 107 |
|
52 |
| - if (withSpilling) { |
53 |
| - Cerr << "LastSimple, -llvm, +spilling" << Endl; |
54 |
| - NKikimr::NMiniKQL::RunTestCombineLastSimple<false, true>(runParams); |
| 108 | +void DoFullPass(bool withSpilling) |
| 109 | +{ |
| 110 | + using namespace NKikimr::NMiniKQL; |
55 | 111 |
|
56 |
| - Cerr << "LastSimple, +llvm, +spilling" << Endl; |
57 |
| - NKikimr::NMiniKQL::RunTestCombineLastSimple<true, true>(runParams); |
| 112 | + TWikiResultCollector printout; |
58 | 113 |
|
59 |
| - Cerr << "LastTpch, -llvm, +spilling" << Endl; |
60 |
| - NKikimr::NMiniKQL::RunTestLastTpch<false, true>(); |
| 114 | + TRunParams runParams; |
61 | 115 |
|
62 |
| - Cerr << "LastTpch, +llvm, +spilling" << Endl; |
63 |
| - NKikimr::NMiniKQL::RunTestLastTpch<true, true>(); |
64 |
| - } |
| 116 | + runParams.NumRuns = 20; |
| 117 | + runParams.RowsPerRun = 5'000'000; |
| 118 | + runParams.MaxKey = 1'00 - 1; |
| 119 | + runParams.LongStringKeys = false; |
| 120 | + |
| 121 | + const std::vector<size_t> numKeys = {4u, 1000u, 100'000u, 200'000u}; |
| 122 | + const std::vector<size_t> blockSizes = {128u, 8192u}; |
| 123 | + |
| 124 | + auto doSimple = [&printout, numKeys](const TRunParams& params) { |
| 125 | + for (size_t keyCount : numKeys) { |
| 126 | + auto runParams = params; |
| 127 | + runParams.MaxKey = keyCount - 1; |
| 128 | + RunTestSimple<false>(runParams, printout); |
| 129 | + RunTestSimple<true>(runParams, printout); |
| 130 | + } |
| 131 | + }; |
| 132 | + |
| 133 | + auto doSimpleLast = [&printout, &numKeys, withSpilling](const TRunParams& params) { |
| 134 | + for (size_t keyCount : numKeys) { |
| 135 | + auto runParams = params; |
| 136 | + runParams.MaxKey = keyCount - 1; |
| 137 | + RunTestCombineLastSimple<false, false>(runParams, printout); |
| 138 | + RunTestCombineLastSimple<true, false>(runParams, printout); |
| 139 | + if (withSpilling) { |
| 140 | + RunTestCombineLastSimple<false, true>(runParams, printout); |
| 141 | + RunTestCombineLastSimple<true, true>(runParams, printout); |
| 142 | + } |
| 143 | + } |
| 144 | + }; |
| 145 | + |
| 146 | + auto doBlockHashed = [&printout, &numKeys, &blockSizes](const TRunParams& params) { |
| 147 | + for (size_t keyCount : numKeys) { |
| 148 | + for (size_t blockSize : blockSizes) { |
| 149 | + auto runParams = params; |
| 150 | + runParams.MaxKey = keyCount - 1; |
| 151 | + runParams.BlockSize = blockSize; |
| 152 | + RunTestBlockCombineHashedSimple<false, false>(runParams, printout); |
| 153 | + } |
| 154 | + } |
| 155 | + }; |
| 156 | + |
| 157 | + doSimple(runParams); |
| 158 | + doSimpleLast(runParams); |
| 159 | + doBlockHashed(runParams); |
65 | 160 | }
|
66 | 161 |
|
67 | 162 | int main(int argc, const char* argv[])
|
|
0 commit comments