Improve planning speed using impl Into<Arc<str>> to create Arc<str> rather than &str#9916
Merged
alamb merged 1 commit intoapache:mainfrom Apr 2, 2024
Merged
Conversation
alamb
commented
Apr 2, 2024
| /// 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 { |
Contributor
Author
There was a problem hiding this comment.
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
Contributor
Author
alamb
commented
Apr 2, 2024
| 1 => { | ||
| let table = taker.take(enable_normalization); | ||
| Ok(OwnedTableReference::bare(&table)) | ||
| Ok(OwnedTableReference::bare(table)) |
Contributor
Author
There was a problem hiding this comment.
somehow it seems the compiler can avoid copying / allocating by getting this as an owned item
comphead
approved these changes
Apr 2, 2024
Contributor
|
I'm planning to deprecate |
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.
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
Stringso making anArc<str>from a&strresults 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