Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3c69ad

Browse files
committed
Fixing Performance-Affecting Regression
Apparently, with the introduction of settings for the receive_buffer,send_buffer, and send/receive low watermarks, responsiveness onpreviously responsive request handling suffers significantly based onlocal benchmarks leading to more timeouts from the client side.By making these options truly optional instead of making them actuallydefault to some value reverses the regression.
1 parent060e1d4 commitc3c69ad

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

‎boost/network/protocol/http/server/socket_options_base.hpp‎

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,34 @@
77
// http://www.boost.org/LICENSE_1_0.txt)
88

99
#include<boost/network/protocol/http/server/parameters.hpp>
10+
#include<boost/optional.hpp>
11+
#include<boost/utility/in_place_factory.hpp>
1012

1113
namespaceboost {namespacenetwork {namespacehttp {
1214

1315
structsocket_options_base {
1416
protected:
1517
asio::socket_base::reuse_address acceptor_reuse_address;
1618
asio::socket_base::enable_connection_aborted acceptor_report_aborted;
17-
asio::socket_base::receive_buffer_size receive_buffer_size;
18-
asio::socket_base::send_buffer_size send_buffer_size;
19-
asio::socket_base::receive_low_watermark receive_low_watermark;
20-
asio::socket_base::send_low_watermark send_low_watermark;
19+
boost::optional<asio::socket_base::receive_buffer_size> receive_buffer_size;
20+
boost::optional<asio::socket_base::send_buffer_size> send_buffer_size;
21+
boost::optional<asio::socket_base::receive_low_watermark> receive_low_watermark;
22+
boost::optional<asio::socket_base::send_low_watermark> send_low_watermark;
2123
asio::socket_base::non_blocking_io non_blocking_io;
2224
asio::socket_base::linger linger;
2325

2426
template<classArgPack>
2527
socket_options_base(ArgPackconst & args)
2628
: acceptor_reuse_address(args[_reuse_address|false])
2729
, acceptor_report_aborted(args[_report_aborted|false])
28-
, receive_buffer_size(args[_receive_buffer_size|4096])
29-
, send_buffer_size(args[_send_buffer_size|4096])
30-
, receive_low_watermark(args[_receive_low_watermark|1024])
31-
, send_low_watermark(args[_send_low_watermark|1024])
3230
, non_blocking_io(args[_non_blocking_io|true])
3331
, linger(args[_linger|true], args[_linger_timeout|0])
34-
{}
32+
{
33+
set_optional(receive_buffer_size, args, _receive_buffer_size);
34+
set_optional(send_buffer_size, args, _send_buffer_size);
35+
set_optional(receive_low_watermark, args, _receive_low_watermark);
36+
set_optional(send_low_watermark, args, _send_low_watermark);
37+
}
3538

3639
voidacceptor_options(boost::asio::ip::tcp::acceptor & acceptor) {
3740
acceptor.set_option(acceptor_reuse_address);
@@ -42,11 +45,40 @@ namespace boost { namespace network { namespace http {
4245
boost::system::error_code ignored;
4346
socket.io_control(non_blocking_io, ignored);
4447
socket.set_option(linger, ignored);
45-
socket.set_option(receive_buffer_size, ignored);
46-
socket.set_option(receive_low_watermark, ignored);
47-
socket.set_option(send_buffer_size, ignored);
48-
socket.set_option(send_low_watermark, ignored);
48+
if (receive_buffer_size) socket.set_option(*receive_buffer_size, ignored);
49+
if (receive_low_watermark) socket.set_option(*receive_low_watermark, ignored);
50+
if (send_buffer_size) socket.set_option(*send_buffer_size, ignored);
51+
if (send_low_watermark) socket.set_option(*send_low_watermark, ignored);
52+
}
53+
54+
private:
55+
56+
template<classOptional,classArgs,classKeyword>
57+
typename boost::enable_if<
58+
mpl::not_<
59+
boost::is_same<
60+
typename boost::parameter::value_type<Args, Keyword,void>::type
61+
,void
62+
>
63+
>
64+
,void
65+
>::type
66+
set_optional(Optional & option, Argsconst & args, Keywordconst & keyword) {
67+
option = in_place<typename Optional::value_type>(args[keyword]);
4968
}
69+
70+
template<classOptional,classArgs,classKeyword>
71+
typename boost::enable_if<
72+
boost::is_same<
73+
typename boost::parameter::value_type<Args, Keyword,void>::type
74+
,void
75+
>
76+
,void
77+
>::type
78+
set_optional(Optional &, Argsconst &, Keywordconst &) {
79+
// do nothing
80+
}
81+
5082
};
5183

5284
}/* http*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp