-
Notifications
You must be signed in to change notification settings - Fork 1.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
sstring causes interoperability problems with other libraries #634
Comments
@avikivity pointed out in the mailing list, "I don't think it's simple. The interfaces are not identical, sstring has several features beyond std::string.". One example I found is the null-termination template parameter introduced in commit 7328d17 which std::basic_string doesn't support, but seastar::basic_sstring does. |
Another difference is that Yet another feature we have and std::string doesn't is |
Another gratuitous difference is that |
That's really a problem in output_stream::write(), it should support iterator+len and iterator pair. |
In commit fc0750b, a compile-time flag SEASTAR_SSTRING was added. Our cmake sets it by default, but if not set, |
I just noticed that although Even better, I don't think that |
The reason why seastar has its own "sstring" type instead of using std::string is historical, due to C++ library implementation when the Seastar projects started: In gcc before version 5, std::string used to use atomic operations which are bad for many-core applications like Seastar. As the nice blog post https://shaharmike.com/cpp/std-string/ explains why this was the case in pre-C++-11 and why gcc for ABI backward-compatibility reasons left this implementation long after 2011. But since gcc 5, this old implementation is gone. Today's std::string implementations in gcc and clang use exactly the same techniques as seastar::sstring does: no atomic operations, and in-structure storage for small strings (a.k.a. "small-string optimization") - the aforementioned blog points out that clang's implementation is particularly clever.
For this reason, seastar::sstring is no longer needed and we can switch to using std::string.
Since Seastar does not care about ABI compatibility (we do not yet support a Seastar shared library - see issue #467), and only about source-code compatibility, it should be easy to change Seastar so that seastar::sstring is merely an alias to std::string, without breaking compatibility for existing applications. Applications can then start gradually changing their own code to use std::string instead of seastar::sstring.
The text was updated successfully, but these errors were encountered: