-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve planning speed using impl Into<Arc<str>>
to create Arc<str> rather than &str
#9916
Conversation
@@ -131,7 +131,7 @@ impl TableReference { | |||
/// As described on [`TableReference`] this does *NO* parsing at | |||
/// all, so "Foo.Bar" stays as a reference to the table named | |||
/// "Foo.Bar" (rather than "foo"."bar") | |||
pub fn bare(table: &str) -> TableReference { | |||
pub fn bare(table: impl Into<Arc<str>>) -> TableReference { |
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.
This PR tests the theory that
pub fn bare(table: impl Into<Arc<str>>) -> TableReference {
will be faster than
pub fn bare(table: &str) -> TableReference {
This comment was marked as outdated.
This comment was marked as outdated.
d21617c
to
c734791
Compare
impl Into<Arc<str>>
impl Into<Arc<str>>
to create Arc<str> rather than &str
@@ -530,18 +530,18 @@ pub(crate) fn idents_to_table_reference( | |||
match taker.0.len() { | |||
1 => { | |||
let table = taker.take(enable_normalization); | |||
Ok(OwnedTableReference::bare(&table)) | |||
Ok(OwnedTableReference::bare(table)) |
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.
somehow it seems the compiler can avoid copying / allocating by getting this as an owned item
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.
lgtm thanks @alamb 🚀
I'm planning to deprecate |
Which issue does this PR close?
Related to #9764. Follow on to #9824
Rationale for this change
On #9824 @comphead saw that using
Arc<String>
made a significant difference in planning benchmarks compared toArc<str>
- #9824 (comment)I believe this is due to the fact that the original data often comes as a
String
so making anArc<str>
from a&str
results in a second copy.It turns out that the Rust compiler is smart enough to avoid copying when using
impl Into<Arc<str>>
-- I thought it was, even though the docs seem to suggest that is not the case.What changes are included in this PR?
Change from
To
Are these changes tested?
yes, by existing CI
Are there any user-facing changes?
Significantly faster performance (5x in at least one case it seems, on select *)
Benchmark Results