Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35189: exec: use go runtime hash functions in hashjoiner r=yuzefovich,jordanlewis a=asubiotto The previous hash functions derived from Java's hashCode implementations were good when it came to deriving a hash that could be used for equality (my understanding is that hashCode is primarily used for this) but the distribution property of these functions was unclear. Additionally hashing was not supported for some types. This commit copies go's non-cryptographic hash functions used for maps to support hashing for all types and get good distribution properties with minimal performance impact. The hash algorithm used is derived from: https://github.com/Cyan4973/xxHash https://github.com/google/cityhash And was tested using https://github.com/aappleby/smhasher. Release note: None The performance impact is noticeable (these are int64 cols), which makes me happy about the hash joiner's performance wrt theoretical limits. Profiles show more CPU usage at the hashing stage as expected. I don't think there's a way to avoid this impact. ``` name old time/op new time/op delta HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=2048-24 299µs ±25% 367µs ± 5% +22.64% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=262144-24 18.1ms ± 1% 19.7ms ± 3% +8.79% (p=0.000 n=9+10) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=4194304-24 266ms ± 2% 294ms ± 2% +10.26% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=2048-24 385µs ± 5% 397µs ± 4% +3.17% (p=0.029 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=262144-24 27.3ms ± 2% 27.6ms ± 3% ~ (p=0.218 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=4194304-24 969ms ± 6% 988ms ± 6% ~ (p=0.123 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=2048-24 360µs ± 2% 363µs ± 6% ~ (p=0.400 n=9+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=262144-24 18.9ms ± 2% 20.7ms ± 3% +9.31% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=4194304-24 281ms ± 2% 310ms ± 1% +10.26% (p=0.000 n=10+9) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=2048-24 391µs ± 4% 402µs ± 6% +2.79% (p=0.043 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=262144-24 26.5ms ± 2% 27.3ms ± 1% +2.99% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=4194304-24 751ms ± 1% 781ms ± 4% +3.94% (p=0.000 n=9+10) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=2048-24 452µs ± 3% 485µs ± 1% +7.14% (p=0.000 n=10+8) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=262144-24 31.0ms ± 2% 33.6ms ± 5% +8.14% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=4194304-24 469ms ± 1% 506ms ± 4% +7.97% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=2048-24 496µs ± 4% 519µs ± 2% +4.67% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=262144-24 42.2ms ± 4% 44.9ms ± 4% +6.24% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=4194304-24 1.48s ± 5% 1.50s ± 2% ~ (p=0.211 n=10+9) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=2048-24 466µs ± 4% 500µs ± 2% +7.28% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=262144-24 31.4ms ± 2% 34.1ms ± 3% +8.62% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=4194304-24 485ms ± 3% 518ms ± 4% +6.83% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=2048-24 516µs ± 4% 517µs ± 2% ~ (p=0.684 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=262144-24 40.1ms ± 3% 42.1ms ± 3% +5.01% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=4194304-24 1.10s ± 4% 1.17s ± 5% +6.12% (p=0.000 n=10+10) name old speed new speed delta HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=2048-24 453MB/s ±29% 358MB/s ± 5% -21.03% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=262144-24 926MB/s ± 1% 852MB/s ± 3% -8.07% (p=0.000 n=9+10) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=4194304-24 1.01GB/s ± 2% 0.91GB/s ± 2% -9.29% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=2048-24 341MB/s ± 5% 331MB/s ± 4% -3.07% (p=0.029 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=262144-24 615MB/s ± 2% 609MB/s ± 3% ~ (p=0.218 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=4194304-24 277MB/s ± 6% 272MB/s ± 6% ~ (p=0.123 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=2048-24 365MB/s ± 2% 362MB/s ± 6% ~ (p=0.400 n=9+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=262144-24 887MB/s ± 2% 812MB/s ± 3% -8.51% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=4194304-24 955MB/s ± 2% 866MB/s ± 1% -9.32% (p=0.000 n=10+9) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=2048-24 335MB/s ± 4% 326MB/s ± 6% -2.67% (p=0.043 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=262144-24 633MB/s ± 3% 614MB/s ± 1% -2.93% (p=0.000 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=4194304-24 357MB/s ± 1% 344MB/s ± 4% -3.76% (p=0.000 n=9+10) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=2048-24 290MB/s ± 3% 270MB/s ± 1% -6.70% (p=0.000 n=10+8) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=262144-24 540MB/s ± 2% 500MB/s ± 5% -7.46% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=4194304-24 573MB/s ± 1% 531MB/s ± 4% -7.31% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=2048-24 264MB/s ± 4% 253MB/s ± 2% -4.46% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=262144-24 397MB/s ± 4% 374MB/s ± 4% -5.87% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=4194304-24 181MB/s ± 5% 179MB/s ± 4% ~ (p=0.143 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=2048-24 281MB/s ± 4% 262MB/s ± 2% -6.81% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=262144-24 534MB/s ± 2% 492MB/s ± 3% -7.89% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=4194304-24 554MB/s ± 3% 519MB/s ± 4% -6.38% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=2048-24 254MB/s ± 5% 253MB/s ± 2% ~ (p=0.684 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=262144-24 419MB/s ± 3% 399MB/s ± 3% -4.76% (p=0.000 n=10+10) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=4194304-24 244MB/s ± 4% 229MB/s ± 3% -6.25% (p=0.000 n=10+9) name old alloc/op new alloc/op delta HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=2048-24 758kB ± 0% 758kB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=262144-24 40.1MB ± 0% 40.1MB ± 0% ~ (p=0.792 n=10+10) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=4194304-24 598MB ± 0% 598MB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=2048-24 779kB ± 0% 779kB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=262144-24 42.5MB ± 0% 42.5MB ± 0% ~ (p=0.240 n=8+10) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=4194304-24 636MB ± 0% 636MB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=2048-24 761kB ± 0% 761kB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=262144-24 40.4MB ± 0% 40.4MB ± 0% ~ (p=0.177 n=10+10) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=4194304-24 602MB ± 0% 602MB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=2048-24 782kB ± 0% 782kB ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=262144-24 42.7MB ± 0% 42.7MB ± 0% ~ (p=0.619 n=8+8) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=4194304-24 640MB ± 0% 640MB ± 0% ~ (p=0.137 n=10+8) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=2048-24 758kB ± 0% 758kB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=262144-24 40.1MB ± 0% 40.1MB ± 0% ~ (p=1.000 n=9+9) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=4194304-24 598MB ± 0% 598MB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=2048-24 779kB ± 0% 779kB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=262144-24 42.5MB ± 0% 42.5MB ± 0% ~ (p=0.373 n=10+9) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=4194304-24 636MB ± 0% 636MB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=2048-24 761kB ± 0% 761kB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=262144-24 40.4MB ± 0% 40.4MB ± 0% ~ (p=0.529 n=8+9) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=4194304-24 602MB ± 0% 602MB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=2048-24 782kB ± 0% 782kB ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=262144-24 42.7MB ± 0% 42.7MB ± 0% -0.00% (p=0.013 n=10+8) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=4194304-24 640MB ± 0% 640MB ± 0% ~ (all equal) name old allocs/op new allocs/op delta HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=2048-24 99.0 ± 0% 99.0 ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=true/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=2048-24 101 ± 0% 101 ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=false/distinct=false/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=2048-24 101 ± 0% 101 ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=true/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=2048-24 103 ± 0% 103 ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=false/fullOuter=true/distinct=false/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=2048-24 99.0 ± 0% 99.0 ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=true/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=2048-24 101 ± 0% 101 ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=false/distinct=false/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=2048-24 101 ± 0% 101 ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=true/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=2048-24 103 ± 0% 103 ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=262144-24 1.71k ± 0% 1.71k ± 0% ~ (all equal) HashJoiner/nulls=true/fullOuter=true/distinct=false/rows=4194304-24 24.8k ± 0% 24.8k ± 0% ~ (all equal) ``` Co-authored-by: Alfonso Subiotto Marqués <[email protected]>
- Loading branch information