-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 perf for string with both strings and chars as argument #27691
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@nanosoldier |
This is still 3x slower than 0.6 though (instead of 12). |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. cc @ararslan |
end | ||
return String(resize!(io.data, io.size)) |
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.
Why not String(take!(io))
?
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 consumes the data rather than making a copy.
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.
In this case, take!
behaves the same way and doesn't make a copy. Ah, but I do understand now, the issue is that take!
also is preparing the IOBuffer
for additional writes, and allocates a new buffer to replace the one that becomes the string.
In Kristoffer's @btime string("foo", 'b', "ar")
, this incurs a 30% penalty. Alright, carry on.
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 wish take!
didn't do that. In the vast majority (all?) of cases, an IOBuffer is not used after take!
is called, so we should at least optimize for that case.
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.
Opened #27741
Before:
After
Ref #27030 (comment)