Repository navigation
GH-40997: [C++] Get null_bit_id according to are_cols_in_encoding_order in NullUpdateColumnToRow_avx2 - #40998
Conversation
|
|
dce2fa9 to
ba0215e
Compare
There was a problem hiding this comment.
Thanks, nice name!
ba0215e to
f4c8949
Compare
|
Any way is it hard to have a unittest here? |
Yes, there are some very special cases need to be constructed here:
|
I will try to figure out a special data set to cover the null_bit_id related case. :) |
The hash join tests cover many different scenarios with random data. Maybe changing the schema to require column re-ordering would be enough to trigger this bug? |
westonpace
left a comment
There was a problem hiding this comment.
I question the merits of reordering the columns in the first place (I never saw benchmarks showing a clear benefit) but the change seems correct to me.
I agree that having a unit test (that detects the regression) in place would be helpful.
Thanks, i'll try it. |
Yes, you're right. I'm confused too. Seems reordering the columns only used in grouper and we currently have no benchmark to prove its benefits, i'll take a look after this PR. |
|
@mapleFU @westonpace PTAL the test, it will cover the case. |
890fdd3 to
07533f9
Compare
I've tested this, looks like a big performance improvement if use the resorted columns (perf shows it's benefit from easier vectorization). origin columns order : GrouperWithResortedColumns/1024/0 68.6 us 68.6 us 10057 bytes_per_second=14.2436Mi/s items_per_second=14.9355M/s null_percent=0 size=1.024k
GrouperWithResortedColumns/2048/0 138 us 138 us 4989 bytes_per_second=14.1325Mi/s items_per_second=14.819M/s null_percent=0 size=2.048k
GrouperWithResortedColumns/4096/0 297 us 297 us 2450 bytes_per_second=13.1419Mi/s items_per_second=13.7803M/s null_percent=0 size=4.096k
GrouperWithResortedColumns/8192/0 635 us 635 us 1026 bytes_per_second=12.3119Mi/s items_per_second=12.91M/s null_percent=0 size=8.192k
GrouperWithResortedColumns/16384/0 1899 us 1899 us 351 bytes_per_second=8.22997Mi/s items_per_second=8.62975M/s null_percent=0 size=16.384k
GrouperWithResortedColumns/32768/10000 4444 us 4441 us 155 bytes_per_second=7.03607Mi/s items_per_second=7.37785M/s null_percent=0.01 size=32.768k
GrouperWithResortedColumns/32768/100 11958 us 11953 us 71 bytes_per_second=2.61451Mi/s items_per_second=2.74151M/s null_percent=1 size=32.768k
GrouperWithResortedColumns/32768/10 29060 us 29048 us 34 bytes_per_second=1.07582Mi/s items_per_second=1.12808M/s null_percent=10 size=32.768k
GrouperWithResortedColumns/32768/2 46366 us 46347 us 30 bytes_per_second=690.451Ki/s items_per_second=707.022k/s null_percent=50 size=32.768k
GrouperWithResortedColumns/32768/1 1089 us 1089 us 644 bytes_per_second=28.699Mi/s items_per_second=30.0931M/s null_percent=100 size=32.768k
GrouperWithResortedColumns/32768/0 4273 us 4271 us 162 bytes_per_second=7.31762Mi/s items_per_second=7.67308M/s null_percent=0 size=32.768kUse origin columns: GrouperWithResortedColumns/1024/0 6628 us 6625 us 100 bytes_per_second=150.947Ki/s items_per_second=154.57k/s null_percent=0 size=1.024k
GrouperWithResortedColumns/2048/0 13385 us 13376 us 100 bytes_per_second=149.516Ki/s items_per_second=153.105k/s null_percent=0 size=2.048k
GrouperWithResortedColumns/4096/0 28524 us 28510 us 130 bytes_per_second=140.303Ki/s items_per_second=143.67k/s null_percent=0 size=4.096k
GrouperWithResortedColumns/8192/0 33133 us 33114 us 66 bytes_per_second=241.59Ki/s items_per_second=247.388k/s null_percent=0 size=8.192k
GrouperWithResortedColumns/16384/0 40724 us 40705 us 33 bytes_per_second=393.073Ki/s items_per_second=402.506k/s null_percent=0 size=16.384k
GrouperWithResortedColumns/32768/10000 57044 us 57008 us 17 bytes_per_second=561.327Ki/s items_per_second=574.799k/s null_percent=0.01 size=32.768k
GrouperWithResortedColumns/32768/100 56691 us 56668 us 16 bytes_per_second=564.691Ki/s items_per_second=578.244k/s null_percent=1 size=32.768k
GrouperWithResortedColumns/32768/10 56045 us 56024 us 17 bytes_per_second=571.188Ki/s items_per_second=584.897k/s null_percent=10 size=32.768k
GrouperWithResortedColumns/32768/2 53605 us 53577 us 25 bytes_per_second=597.276Ki/s items_per_second=611.61k/s null_percent=50 size=32.768k
GrouperWithResortedColumns/32768/1 1102 us 1102 us 643 bytes_per_second=28.3595Mi/s items_per_second=29.7371M/s null_percent=100 size=32.768k
GrouperWithResortedColumns/32768/0 54583 us 54560 us 17 bytes_per_second=586.508Ki/s items_per_second=600.585k/s null_percent=0 size=32.768kI'll add more tests on it and push the benchmark in another pr. |
westonpace
left a comment
There was a problem hiding this comment.
I've tested this, looks like a big performance improvement if use the resorted columns (perf shows it's benefit from easier vectorization).
Thank you for both the test and the benchmark!
07533f9 to
b14cdf2
Compare
|
Can this PR be moved forward? We recently encountered this problem in Aggregate-Node. :( |
There is a bug when set When i fix the |
|
cc @pitrou @zanmato1984 Would you mind take a look? I've check the logic here but I'm not familiar enough with here |
|
Maybe a dumb question. Seems the column sorting will happen anyway in encoding [1], how can [1] [2] arrow/cpp/src/arrow/compute/row/grouper.cc Line 582 in 63c91ff |
It's nice question! Use
|
Ah I see now, thank you for explaining this to me! |
zanmato1984
left a comment
There was a problem hiding this comment.
nit:
Quoting from your other PR [1]:
And also, the purpose of the column-sort in RowTableEncoder is construct an aligned friendly condition for memory access. Resorted order will be used to produce an aligned column_offset for access the row data in encode/decode/compare.
Since I saw different people confused about the column sorting, maybe you can update the comment in [2] with the quote.
[1] #41036 (comment)
[2]
b14cdf2 to
74b4e9f
Compare
zanmato1984
left a comment
There was a problem hiding this comment.
Suggested comment tuning. Didn't format.
74b4e9f to
d69e609
Compare
|
@pitrou do you have some comment on this? If no negative comment, I'll merge this patch in 3days |
d69e609 to
ff0cea2
Compare
|
@github-actions crossbow submit -g cpp |
|
Revision: ff0cea2 Submitted crossbow builds: ursacomputing/crossbow @ actions-21cd06c87f |
|
After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 5232137. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 44 possible false positives for unstable benchmarks that are known to sometimes produce them. |
…gression (#41036) ### Rationale for this change Add a grouper benchmark for preventing performance regression . #40998 (comment). ### What changes are included in this PR? Added a benchmark. ### Are these changes tested? Needn't. ### Are there any user-facing changes? No * GitHub Issue: #41035 Authored-by: ZhangHuiGui <hugo.zhang@openpie.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
…ng_order in NullUpdateColumnToRow_avx2 (apache#40998) ### Rationale for this change Recently, we find that the compare internal's avx2 function NullUpdateColumnToRowImp_avx2 lost the are_cols_in_encoding_order check when get null_bit_id. It may cause grouper's compare result wrong(are_cols_in_encoding_order = true in grouper). ### What changes are included in this PR? Get `null_bit_id` according to `are_cols_in_encoding_order` in NullUpdateColumnToRow_avx2. ### Are there any user-facing changes? No Co-authored-by laotan332 <qinpengxiang@ outlook.com> Co-authored-by ZhangHuiGui <2689496754@ qq.com> * GitHub Issue: apache#40997 Lead-authored-by: ZhangHuiGui <hugo.zhang@openpie.com> Co-authored-by: ZhangHuiGui <2689496754@qq.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
…nce regression (apache#41036) ### Rationale for this change Add a grouper benchmark for preventing performance regression . apache#40998 (comment). ### What changes are included in this PR? Added a benchmark. ### Are these changes tested? Needn't. ### Are there any user-facing changes? No * GitHub Issue: apache#41035 Authored-by: ZhangHuiGui <hugo.zhang@openpie.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
Rationale for this change
Recently, we find that the compare internal's avx2 function NullUpdateColumnToRowImp_avx2 lost the are_cols_in_encoding_order check when get null_bit_id. It may cause grouper's compare result wrong(are_cols_in_encoding_order = true in grouper).
What changes are included in this PR?
Get
null_bit_idaccording toare_cols_in_encoding_orderin NullUpdateColumnToRow_avx2.Are there any user-facing changes?
No
Co-authored-by laotan332 qinpengxiang@outlook.com
Co-authored-by ZhangHuiGui 2689496754@qq.com