-
Couldn't load subscription status.
- Fork 43
Concludes the work on the generic_flat_response started by Nikolai Vladimirov #340
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
base: develop
Are you sure you want to change the base?
Conversation
…ew response type in tests
|
Do we have any numbers comparing the performance of this approach (converting to string_view immediately after parsing) vs. the custom iterator approach (converting to string_view on iteration)? I will have a look at this tomorrow |
IMO this is not worth the effort. Both cases must contruct construct the Performance however is not my main concern because it is probably in sub microsend difference, which is hard to measure. In essence I regard the
Thanks. Please, take into account I hurried a bit to ovoid delaying discussion another week, specially on what we should do with |
|
The only thing I'm not convinced of is exposing this new I'm writing some benchmarks and thinking to see if there is any chance of using Testing and docs could use a couple of improvements, but I don't think there's a need to delay merging this because of these two - I can make some improvements later. |
|
Concluded the benchmarks. TL;DR: let's use the separate Benchmark results (explanation follows):
Full code: https://gist.github.com/anarthal/73a8e081dc9de3f390e6d0ec1d5e2b34 Implementations:
The benchmarks:
The custom buffer approach seems consistently faster in all benchmarks. It's however much more implementation work, so I'd discourage from taking this way at least for now. The other two options seem similar. offset_vector would allow us to get rid of offset_string, so I suggest taking this path. |
| if (MSVC) | ||
| # C4459: name hides outer scope variable is issued by Asio | ||
| target_compile_options(boost_redis_project_options INTERFACE /bigobj /W4 /WX /wd4459) | ||
| target_compile_options(boost_redis_project_options INTERFACE /bigobj /W4 /WX /wd4459 /w34996) |
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.
We shouldn't need this or -Wno-deprecated-declarations. We already define BOOST_ALLOW_DEPRECATED in the tests, and examples shouldn't use deprecated features.
| #include <boost/system/error_code.hpp> | ||
|
|
||
| #include <string> | ||
| #include <tuple> |
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.
Unused include
| * much memory to reserve upfront. | ||
| */ | ||
| auto get_reallocs() const noexcept | ||
| { return reallocs_; } |
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.
Better use explicit return type here
|
|
||
| /// @copydoc basic_connection::async_receive | ||
| template <class CompletionToken = asio::deferred_t> | ||
| BOOST_DEPRECATED("Please use async_receive2 instead.") |
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.
You probably need -Wno-deprecated-declarations and friends because impl_.async_receive and impl_.receive are deprecated. This means that the user is going to see these warnings when they build src.hpp, and we don't want this.
The way I usually solve this is by moving the function from basic_connection to connection_impl, then calling this second function from both basic_connection and connection.
| { return reallocs_; } | ||
|
|
||
| // Notify the object that all nodes were pushed. | ||
| void notify_done(); |
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.
These should be made private with a detail accessor. But this is not urgent, I can do it afterwards.
| { | ||
| net::io_context ioc; | ||
| auto conn = std::make_shared<connection>(ioc); | ||
|
|
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.
We should retain at least one test for the deprecated async_receive and receive so we make sure we don't break them by accident. I suggest duplicating this test to get a minimum of coverage.
| * | ||
| * @param r The response to modify. | ||
| */ | ||
| /// @copydoc consume_one |
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.
There seems to be a MrDocs bug with copydoc and this seems to fail. It doesn't support Doxygen's overload resolution either (cppalliance/mrdocs#842). Since this is deprecated, I suggest keeping the old docs stating that the function is deprecated and go.
| * contiguously, this helps reducing memory allocations and improves | ||
| * memory reuse. | ||
| */ | ||
| using generic_flat_response = adapter::result<generic_flat_response_value>; |
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.
New classes should be added to the reference page. If you'd like, please open an issue and I'll add it after you merge it.
|
|
||
| /// Returns the number of complete RESP3 messages contained in this object. | ||
| std::size_t get_total_msgs() const noexcept | ||
| { return total_msgs_; } |
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 completely forgot - but this class copy semantics are wrong. You will get string_views pointing to the old class. You will need to implement a custom copy constructor and copy assignment. You might also mark these operations as deleted for now and implement them later on.
@anarthal, let us start the review for
generic_flat_response. I need theasync_receive2so I committed my own implementation and will rebase on top of yours if you find time to implement it.