[enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate#10259
Merged
yiguolei merged 2 commits intoapache:masterfrom Jun 20, 2022
Merged
[enhancement] optmize 2 cases in seg_iter: all/none rows passed predicate#10259yiguolei merged 2 commits intoapache:masterfrom
yiguolei merged 2 commits intoapache:masterfrom
Conversation
yiguolei
reviewed
Jun 20, 2022
| 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) { |
Contributor
There was a problem hiding this 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.
englefly
commented
Jun 20, 2022
| 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; |
Contributor
Author
There was a problem hiding this comment.
“0 == num_zeros ” means all rows passed the predicate, we should set all of them in sel_rowid_idx array
freesinger
pushed a commit
to freesinger/incubator-doris
that referenced
this pull request
Jun 21, 2022
…cate (apache#10259) * [enhancement] optmize 2 cases: all/none rows passed predicate in seg_iter. * format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Furthermore, if the 32-char part of ret_flags is 0 or 0xfffffff, the implementation also optimized.
test results:
select count(LO_ORDERDATE) from lineorder where LO_ORDERDATE >=19920101;
ssb100G
before:3.74sec
after: 3.37sec
Issue Number: close #xxx
Problem Summary:
Describe the overview of changes.
Checklist(Required)
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...