-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StrCat: do not use intermediate buffer when result fits in SSO.
PiperOrigin-RevId: 557811632 Change-Id: I370fa17d2fb82a1f1ca86f84529bae31b34b18e4
- Loading branch information
1 parent
9377c75
commit 65d7b6d
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
65d7b6d
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.
@derekmauro
It's possible to use this optimization only for libc++?
Just make this code under
defined(_LIBCPP_VERSION)
?Because for other libraries it will be always allocate string, even in cases when it's not necessary
Also if you're interested in optimization of StrCat:
Now AlphaNum always stored buffer which length is 32
Did you try to use different buffer size for different ctor?
65d7b6d
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 was neither the author nor a reviewer of this change, but I agree that this looks like a regression when not using libc++.
I believe the two issues here are that
STLStringResizeUninitialized
on libstdc++ or MSSTL.I'll get this patched. It's a bit unfortunate that since our production platform uses libc++, many changes don't get benchmarked on other platforms, so thank you for reporting this.
Now there are a lot of recent changes to this code to support
AbslStringify
that I haven't followed too closely. Can you say more about the other optimization you have in mind?65d7b6d
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.
Yes, I know, I can't understand why libstdc++ cannot make some members public :(
I know folly makes access to the private fields, but it looks like it generates a lot of templates
Thanks! I appreciate that
I will make an issue
65d7b6d
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.
@derekmauro #1530 (comment) done.
65d7b6d
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.
f3eae68 fixes the performance regression.