You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/20 06:51:31 UTC
[GitHub] [doris] englefly opened a new pull request, #10259: [enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate
englefly opened a new pull request, #10259:
URL: https://github.com/apache/doris/pull/10259
# Proposed changes
After vec_predicate, doris generates the array sel_rowid_idx for selected rows from 0/1 array ret_flags.
This pr implements a short cut for 2 cases:
- all rows are passed predicate
- none row is passed
Furthermore, if the 32-char part of ret_flags is 0 or 0xfffffff, the implementation also optimized.
Issue Number: close #xxx
## Problem Summary:
Describe the overview of changes.
## Checklist(Required)
1. Does it affect the original behavior: (Yes/No/I Don't know)
2. Has unit tests been added: (Yes/No/No Need)
3. Has document been added or modified: (Yes/No/No Need)
4. Does it need to update dependencies: (Yes/No)
5. Are there any changes that cannot be rolled back: (Yes/No)
test:
select count(LO_ORDERDATE) from lineorder where LO_ORDERDATE >=19920101;
ssb100G
before:3.74sec
after: 3.37sec
## Further comments
If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] yiguolei merged pull request #10259: [enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate
Posted by GitBox <gi...@apache.org>.
yiguolei merged PR #10259:
URL: https://github.com/apache/doris/pull/10259
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] yiguolei commented on a diff in pull request #10259: [enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate
Posted by GitBox <gi...@apache.org>.
yiguolei commented on code in PR #10259:
URL: https://github.com/apache/doris/pull/10259#discussion_r901324735
##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -859,40 +859,50 @@ Status SegmentIterator::_read_columns_by_index(uint32_t nrows_read_limit, uint32
void SegmentIterator::_evaluate_vectorization_predicate(uint16_t* sel_rowid_idx,
uint16_t& selected_size) {
SCOPED_RAW_TIMER(&_opts.stats->vec_cond_ns);
- if (!_is_need_vec_eval) {
Review Comment:
If _pre_eval_block_predicate is empty, the original code is faster. Because it does not need init ret_flags and call memset to init it and call simd count zero num to calculate it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] englefly commented on a diff in pull request #10259: [enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate
Posted by GitBox <gi...@apache.org>.
englefly commented on code in PR #10259:
URL: https://github.com/apache/doris/pull/10259#discussion_r901330938
##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -871,28 +871,45 @@ void SegmentIterator::_evaluate_vectorization_predicate(uint16_t* sel_rowid_idx,
memset(ret_flags, 1, selected_size);
_pre_eval_block_predicate->evaluate_vec(_current_return_columns, selected_size, ret_flags);
- uint32_t sel_pos = 0;
- const uint32_t sel_end = sel_pos + selected_size;
- static constexpr size_t SIMD_BYTES = 32;
- const uint32_t sel_end_simd = sel_pos + selected_size / SIMD_BYTES * SIMD_BYTES;
uint16_t new_size = 0;
-
- while (sel_pos < sel_end_simd) {
- auto mask = simd::bytes32_mask_to_bits32_mask(ret_flags + sel_pos);
- while (mask) {
- const size_t bit_pos = __builtin_ctzll(mask);
- sel_rowid_idx[new_size++] = sel_pos + bit_pos;
- mask = mask & (mask - 1);
+ size_t num_zeros = simd::count_zero_num(reinterpret_cast<int8_t*>(ret_flags), original_size);
+ if (0 == num_zeros) {
+ for (uint16_t i = 0; i < original_size; i++) {
+ sel_rowid_idx[i] = i;
Review Comment:
“0 == num_zeros ” means all rows passed the predicate, we should set all of them in sel_rowid_idx array
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] yiguolei commented on a diff in pull request #10259: [enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate
Posted by GitBox <gi...@apache.org>.
yiguolei commented on code in PR #10259:
URL: https://github.com/apache/doris/pull/10259#discussion_r901328169
##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -871,28 +871,45 @@ void SegmentIterator::_evaluate_vectorization_predicate(uint16_t* sel_rowid_idx,
memset(ret_flags, 1, selected_size);
_pre_eval_block_predicate->evaluate_vec(_current_return_columns, selected_size, ret_flags);
- uint32_t sel_pos = 0;
- const uint32_t sel_end = sel_pos + selected_size;
- static constexpr size_t SIMD_BYTES = 32;
- const uint32_t sel_end_simd = sel_pos + selected_size / SIMD_BYTES * SIMD_BYTES;
uint16_t new_size = 0;
-
- while (sel_pos < sel_end_simd) {
- auto mask = simd::bytes32_mask_to_bits32_mask(ret_flags + sel_pos);
- while (mask) {
- const size_t bit_pos = __builtin_ctzll(mask);
- sel_rowid_idx[new_size++] = sel_pos + bit_pos;
- mask = mask & (mask - 1);
+ size_t num_zeros = simd::count_zero_num(reinterpret_cast<int8_t*>(ret_flags), original_size);
+ if (0 == num_zeros) {
+ for (uint16_t i = 0; i < original_size; i++) {
+ sel_rowid_idx[i] = i;
Review Comment:
These code is useless.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris] yiguolei commented on a diff in pull request #10259: [enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate
Posted by GitBox <gi...@apache.org>.
yiguolei commented on code in PR #10259:
URL: https://github.com/apache/doris/pull/10259#discussion_r901324735
##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -859,40 +859,50 @@ Status SegmentIterator::_read_columns_by_index(uint32_t nrows_read_limit, uint32
void SegmentIterator::_evaluate_vectorization_predicate(uint16_t* sel_rowid_idx,
uint16_t& selected_size) {
SCOPED_RAW_TIMER(&_opts.stats->vec_cond_ns);
- if (!_is_need_vec_eval) {
Review Comment:
If _pre_eval_block_predicate is empty, the original code is faster. Because it does not need init ret_flags and call memset to init it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org