-
-
Notifications
You must be signed in to change notification settings - Fork 69
add key-value file! #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
8335a0b
156142a
473427c
a05f062
fad1753
7821e01
ae02b58
5363ba4
cd836c7
541f914
8873ea1
7ea8230
09ef43a
17b534c
4927fe2
e73aa3f
b73ba45
c083424
ecc94cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Prerequisites | ||
| *.d | ||
|
|
||
| # Compiled Object files | ||
| *.slo | ||
| *.lo | ||
| *.o | ||
| *.obj | ||
|
|
||
| # Precompiled Headers | ||
| *.gch | ||
| *.pch | ||
|
|
||
| # Compiled Dynamic libraries | ||
| *.so | ||
| *.dylib | ||
| *.dll | ||
|
|
||
| # Fortran module files | ||
| *.mod | ||
| *.smod | ||
|
|
||
| # Compiled Static libraries | ||
| *.lai | ||
| *.la | ||
| *.a | ||
| *.lib | ||
|
|
||
| # Executables | ||
| *.exe | ||
| *.out | ||
| *.app | ||
|
|
||
| **/.vscode | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,29 @@ | ||
| |-----------------+-------------+------------+-----------------+-----------+----------| | ||
| | Array data type | typeid name | array size | avx512_qsort<T> | std::sort | speed up | | ||
| |-----------------+-------------+------------+-----------------+-----------+----------| | ||
| | uniform random | uint32_t | 10000 | 115697 | 1579118 | 13.6 | | ||
| | uniform random | uint32_t | 100000 | 1786812 | 19973203 | 11.2 | | ||
| | uniform random | uint32_t | 1000000 | 22536966 | 233470422 | 10.4 | | ||
| | uniform random | int32_t | 10000 | 95591 | 1569108 | 16.4 | | ||
| | uniform random | int32_t | 100000 | 1790362 | 19785007 | 11.1 | | ||
| | uniform random | int32_t | 1000000 | 22874571 | 233358497 | 10.2 | | ||
| | uniform random | float | 10000 | 113316 | 1668407 | 14.7 | | ||
| | uniform random | float | 100000 | 1920018 | 21815024 | 11.4 | | ||
| | uniform random | float | 1000000 | 24776954 | 256867990 | 10.4 | | ||
| | uniform random | uint64_t | 10000 | 233501 | 1537649 | 6.6 | | ||
| | uniform random | uint64_t | 100000 | 3991372 | 19559859 | 4.9 | | ||
| | uniform random | uint64_t | 1000000 | 49818870 | 232687666 | 4.7 | | ||
| | uniform random | int64_t | 10000 | 228000 | 1445131 | 6.3 | | ||
| | uniform random | int64_t | 100000 | 3892092 | 18917322 | 4.9 | | ||
| | uniform random | int64_t | 1000000 | 48957088 | 235100259 | 4.8 | | ||
| | uniform random | double | 10000 | 180307 | 1702801 | 9.4 | | ||
| | uniform random | double | 100000 | 3596886 | 21849587 | 6.1 | | ||
| | uniform random | double | 1000000 | 47724381 | 258014177 | 5.4 | | ||
| | uniform random | uint16_t | 10000 | 84732 | 1548275 | 18.3 | | ||
| | uniform random | uint16_t | 100000 | 1406417 | 19632858 | 14.0 | | ||
| | uniform random | uint16_t | 1000000 | 17119960 | 214085305 | 12.5 | | ||
| | uniform random | int16_t | 10000 | 84703 | 1547726 | 18.3 | | ||
| | uniform random | int16_t | 100000 | 1442726 | 19705242 | 13.7 | | ||
| | uniform random | int16_t | 1000000 | 20210224 | 212137465 | 10.5 | | ||
| |-----------------+-------------+------------+-----------------+-----------+----------| | ||
| | -----------------+-------------+------------+-----------------+-----------+---------- | | ||
| | Array data type | typeid name | array size | ||
| | avx512_qsort<T> | std::sort | speed up | | ||
| | -----------------+-------------+------------+-----------------+-----------+---------- | | ||
| | uniform random | uint32_t | 10000 | 115697 | 1579118 | 13.6 | | ||
| | uniform random | uint32_t | 100000 | 1786812 | 19973203 | 11.2 | | ||
| | uniform random | uint32_t | 1000000 | 22536966 | 233470422 | 10.4 | | ||
| | uniform random | int32_t | 10000 | 95591 | 1569108 | 16.4 | | ||
| | uniform random | int32_t | 100000 | 1790362 | 19785007 | 11.1 | | ||
| | uniform random | int32_t | 1000000 | 22874571 | 233358497 | 10.2 | | ||
| | uniform random | float | 10000 | 113316 | 1668407 | 14.7 | | ||
| | uniform random | float | 100000 | 1920018 | 21815024 | 11.4 | | ||
| | uniform random | float | 1000000 | 24776954 | 256867990 | 10.4 | | ||
| | uniform random | uint64_t | 10000 | 233501 | 1537649 | 6.6 | | ||
| | uniform random | uint64_t | 100000 | 3991372 | 19559859 | 4.9 | | ||
| | uniform random | uint64_t | 1000000 | 49818870 | 232687666 | 4.7 | | ||
| | uniform random | int64_t | 10000 | 228000 | 1445131 | 6.3 | | ||
| | uniform random | int64_t | 100000 | 3892092 | 18917322 | 4.9 | | ||
| | uniform random | int64_t | 1000000 | 48957088 | 235100259 | 4.8 | | ||
| | uniform random | double | 10000 | 180307 | 1702801 | 9.4 | | ||
| | uniform random | double | 100000 | 3596886 | 21849587 | 6.1 | | ||
| | uniform random | double | 1000000 | 47724381 | 258014177 | 5.4 | | ||
| | uniform random | uint16_t | 10000 | 84732 | 1548275 | 18.3 | | ||
| | uniform random | uint16_t | 100000 | 1406417 | 19632858 | 14.0 | | ||
| | uniform random | uint16_t | 1000000 | 17119960 | 214085305 | 12.5 | | ||
| | uniform random | int16_t | 10000 | 84703 | 1547726 | 18.3 | | ||
| | uniform random | int16_t | 100000 | 1442726 | 19705242 | 13.7 | | ||
| | uniform random | int16_t | 1000000 | 20210224 | 212137465 | 10.5 | | ||
| | -----------------+-------------+------------+-----------------+-----------+---------- | | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,19 @@ | |
|
|
||
| #include "avx512-16bit-qsort.hpp" | ||
| #include "avx512-32bit-qsort.hpp" | ||
| #include "avx512-64bit-keyvaluesort.hpp" | ||
| #include "avx512-64bit-qsort.hpp" | ||
| #include <iostream> | ||
| #include <numeric> | ||
| #include <tuple> | ||
| #include <vector> | ||
|
|
||
| template <typename K, typename V> | ||
| struct sorted_t { | ||
| K key; | ||
| V value; | ||
| }; | ||
|
|
||
| static inline uint64_t cycles_start(void) | ||
| { | ||
| unsigned a, d; | ||
|
|
@@ -72,3 +79,49 @@ std::tuple<uint64_t, uint64_t> bench_sort(const std::vector<T> arr, | |
| / lastfew; | ||
| return std::make_tuple(avx_sort, std_sort); | ||
| } | ||
| template <typename K, typename V = uint64_t> | ||
| std::tuple<uint64_t, uint64_t> | ||
| bench_sort_kv(const std::vector<K> keys, | ||
| const std::vector<V> values, | ||
| const std::vector<sorted_t<K, V>> sortedaar, | ||
| const uint64_t iters, | ||
| const uint64_t lastfew) | ||
| { | ||
|
|
||
| std::vector<K> keys_bckup = keys; | ||
| std::vector<V> values_bckup = values; | ||
| std::vector<sorted_t<K, V>> sortedaar_bckup = sortedaar; | ||
|
|
||
| std::vector<uint64_t> runtimes1, runtimes2; | ||
| uint64_t start(0), end(0); | ||
| for (uint64_t ii = 0; ii < iters; ++ii) { | ||
| start = cycles_start(); | ||
| avx512_qsort_kv<K>( | ||
| keys_bckup.data(), values_bckup.data(), keys_bckup.size()); | ||
| end = cycles_end(); | ||
| runtimes1.emplace_back(end - start); | ||
| keys_bckup = keys; | ||
| values_bckup = values; | ||
| } | ||
| uint64_t avx_sort = std::accumulate(runtimes1.end() - lastfew, | ||
| runtimes1.end(), | ||
| (uint64_t)0) | ||
| / lastfew; | ||
|
|
||
| for (uint64_t ii = 0; ii < iters; ++ii) { | ||
| start = cycles_start(); | ||
| std::sort(sortedaar_bckup.begin(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if std::sort is a fair comparison. The way the key-values are arranged in memory for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ObStoreRow is the base unit to do the sort in Oceanbase. The key and value are all ObObject class type in the ObStoreRow. There is no sperate vector for key and value. The ObStoreRow is passed to the std::sort in Oceanbase. std::sort first get the key type from ObObject and then do the sort work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To enable the AVX512 sort, we need extract the key from the ObStoreRow and then pass the key and ObStoreRow as the value to avx512_sort(key, value) like API. That's way we need the key-value interface |
||
| sortedaar_bckup.end(), | ||
| [](sorted_t<K, V> a, sorted_t<K, V> b) { | ||
| return a.key < b.key; | ||
| }); | ||
| end = cycles_end(); | ||
| runtimes2.emplace_back(end - start); | ||
| sortedaar_bckup = sortedaar; | ||
| } | ||
| uint64_t std_sort = std::accumulate(runtimes2.end() - lastfew, | ||
| runtimes2.end(), | ||
| (uint64_t)0) | ||
| / lastfew; | ||
| return std::make_tuple(avx_sort, std_sort); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.