antonmks / Alenka

GPU database engine
Other
1.17k stars 120 forks source link

Optimize sort strings (speedup in 2 - 8 times). #32

Closed AlexeyAB closed 11 years ago

AlexeyAB commented 11 years ago
antonmks commented 11 years ago

Excellent, so now it makes sense to round up the possible lengths of varchars to 4 or 8 bytes.

AlexeyAB commented 11 years ago

Yes, you right! The general rule for my optimization - rounding up to a multiple of four the length:

Radix_sort very optimized algorithm on CUDA. Round up must be such as: 3 -> 4 5, 6, 7 -> 8

And CUDA is very sensitive to aligned data, like all SIMD processors! All strings with odd length -> to an even length, or better to length is a multiple of four. An example round up length 25 -> 28 etc.

I wrote a benchmark of different variants of sorting strings.

Results for variant which I added to Alenka, such: https://github.com/AlexeyAB/Benchmarks/tree/687d265ff8b38ed02dc7837b1d29d5825611d6ec/CUDA_sort_strings_bench Comparing speedup and perfomance for strings with different lengthes.

Speedup through round up to fundamental types:

Speedup sort strings with length equal to fundamental types:

Speedup through optimize of comparison of static strings: