-
Notifications
You must be signed in to change notification settings - Fork 1.9k
perf: improve range and generate_series for Int64
#19431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: improve range and generate_series for Int64
#19431
Conversation
|
run benchmark range_and_generate_series |
|
🤖 |
|
@alamb I might increased the benchmark too much, is it stuck? |
|
show benchmark queue |
| } | ||
| } else { | ||
| // step < 0 | ||
| let cur = series_state.current as i128; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the same effect be achieved using a reverse iterator like:
(series_state.end..=series_state.current).rev()
Depending on whether end is exclusive or not, you may have to offset it by one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave it a go locally. This seems to do the trick:
if series_state.include_end {
Int64Array::from_iter_values(
(series_state.end..=series_state.current)
.rev()
.step_by(-series_state.step as usize)
.take(series_state.batch_size),
)
} else {
Int64Array::from_iter_values(
((series_state.end + 1)..=series_state.current)
.rev()
.step_by(-series_state.step as usize)
.take(series_state.batch_size),
)
}
pepijnve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added review comments
|
🤖 |
I don't know what happened -- the runner had died. I restarted t |
|
🤖: Benchmark completed Details
|
|
These cases seems to have slowed down Is that expected? |
|
run benchmark range_and_generate_series |
|
|
||
| # generate_series equal batch size * 2 with starting value and step (including end) | ||
| query I | ||
| SELECT * FROM generate_series(1, 39, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also add a test for a starting value other than 1? Perhaps 100 and -100?
|
🤖 |
|
🤖: Benchmark completed Details
|
|
Closing as it is fast enough and this have some regression |
Which issue does this PR close?
N/A
Rationale for this change
make
rangeandgenerate_seriesfasterWhat changes are included in this PR?
manually implement specialized implementation for Int64
rangeandgenerate_seriesAre these changes tested?
Existing tests + added more tests for edge cases
Are there any user-facing changes?
Yes, added to public trait
SeriesValuea function calledgenerate_array_for_serieswith default implementation to avoid breaking changes