Skip to content
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

stable expressions as constant in vectorized filters #6203

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

akuzm
Copy link
Member

@akuzm akuzm commented Oct 17, 2023

This means vectorizing very common filters such as ts > now() - interval '1 day'.

The only query with stable expressions we have in tsbench shows a 130% improvement:
https://grafana.ops.savannah-dev.timescale.com/d/fasYic_4z/compare-akuzm?orgId=1&var-branch=All&var-run1=2853&var-run2=2855&var-threshold=0.05&var-use_historical_thresholds=false

Disable-check: force-changelog-file

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #6203 (f8b67e1) into main (22b556d) will increase coverage by 0.09%.
Report is 3 commits behind head on main.
The diff coverage is 93.22%.

@@            Coverage Diff             @@
##             main    #6203      +/-   ##
==========================================
+ Coverage   65.19%   65.28%   +0.09%     
==========================================
  Files         247      247              
  Lines       57271    57480     +209     
  Branches    12732    12765      +33     
==========================================
+ Hits        37337    37525     +188     
- Misses      18055    18089      +34     
+ Partials     1879     1866      -13     
Files Coverage Δ
tsl/src/nodes/decompress_chunk/planner.c 88.25% <100.00%> (+0.67%) ⬆️
tsl/src/nodes/decompress_chunk/compressed_batch.c 89.71% <50.00%> (ø)
tsl/src/nodes/decompress_chunk/exec.c 92.93% <86.95%> (-0.44%) ⬇️

... and 72 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@akuzm akuzm marked this pull request as ready for review November 2, 2023 10:42
Copy link

github-actions bot commented Nov 2, 2023

@fabriziomello, @gayyappan: please review this pull request.

Powered by pull-review

return (func_volatile(func_id) == PROVOLATILE_VOLATILE);
}

static bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function contains some logic. So, could you add a comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 I believe you are just looking for expressions that can be constified at runtime (as opposed to plantime) here. It would help to add a comment.

I was thrown off by the commit message that said we can now support ts> now() - '1 day'::interval. We already do plan time constification for that in some cases. I suggest also modifying the commit message to elaborate that this change now introduces support for ts < now() , ts> now() etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already do plan time constification for that in some cases.

That's a different thing, it's for runtime chunk exclusion that is done in this small scope only IIRC. The underlying DecompressChunk executor doesn't see the constified values, and I don't think there's a good way to pass these values down to the underlying nodes. So what I'm doing is also constifying the values there, so that we can perform vectorized filters with them.

I'll try to improve the comments and the message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. To clarify: ts > now() - <> works with plantime chunk exclusion. But I wasn't aware that it doesn't get passed along via the filters to decompress.

Copy link
Contributor

@jnidzwetzki jnidzwetzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice speedup, one minor comment. Rest LGTM.

This allows vectorizing common filters such as ts > now() - interval '1 day'.
@akuzm akuzm enabled auto-merge (rebase) November 3, 2023 10:30
@akuzm akuzm merged commit 61f2606 into timescale:main Nov 3, 2023
35 checks passed
@akuzm akuzm deleted the stable-vector branch November 3, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants