-
Notifications
You must be signed in to change notification settings - Fork 4k
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
limiting max bytes in stream comsume queue with the same host socket #1958
limiting max bytes in stream comsume queue with the same host socket #1958
Conversation
chenbay
commented
Oct 19, 2022
- Add socket_max_streams_unconsumed_bytes to socket for limiting max bytes in stream comsume queue with the same host socket.
- Add min_buffer_size to stream options and remain_buffer_size to message Feedback for stream buffer control.
6de002a
to
2913a93
Compare
src/brpc/stream.cpp
Outdated
|
||
if (FLAGS_socket_max_streams_unconsumed_bytes > 0) { | ||
_host_socket->_total_streams_unconsumed_size -= new_remote_consumed - _remote_consumed; | ||
if (_host_socket->_total_streams_unconsumed_size <= FLAGS_socket_max_streams_unconsumed_bytes) { |
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 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.
是的,= =
src/brpc/stream.cpp
Outdated
@@ -72,6 +74,11 @@ int Stream::Create(const StreamOptions &options, | |||
s->_connected = false; | |||
s->_options = options; | |||
s->_closed = false; | |||
s->_cur_max_buf_size = options.max_buf_size; | |||
if (FLAGS_socket_max_streams_unconsumed_bytes > 0 && options.min_buf_size > 0) { |
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.
需要判断 min_buf_size < max_buf_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.
嗯可以改下,这里本来是考虑max_buf_size=0要不限制。
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.
此处应使用s->_options.min_buf_size
src/brpc/stream_impl.h
Outdated
@@ -114,6 +114,7 @@ friend class MessageBatcher; | |||
bthread_mutex_t _congestion_control_mutex; | |||
size_t _produced; | |||
size_t _remote_consumed; | |||
size_t _cur_max_buf_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.
有了min_buf_size和max_buf_size,这个叫_cur_buf_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.
咋说呢,其实也是max_buf_size,毕竟少用也是可以的,,大概是capacity的意思。
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.
_cur_buf_size
我先改成_cur_buf_size把
2913a93
to
ae1d397
Compare
@wwbmmm ok |
编译失败且有warning,@chenbay src/brpc/stream.cpp:81:30: error: cannot assign to variable 'options' with
const-qualified type 'const brpc::StreamOptions &'
options.min_buf_size = 0;
~~~~~~~~~~~~~~~~~~~~ ^
src/brpc/stream.cpp:68:41: note: variable 'options' declared const here
int Stream::Create(const StreamOptions &options,
~~~~~~~~~~~~~~~~~~~~~^~~~~~~
src/brpc/stream.cpp:326:117: warning: comparison of integers of different signs:
'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
...(_options.max_buf_size == 0 || _cur_buf_size < _options.max_buf_size)) {
~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
src/brpc/stream.cpp:327:64: warning: comparison of integers of different signs:
'unsigned long' and 'int' [-Wsign-compare]
...> 0 && _cur_buf_size * 2 > _options.max_buf_size) {
~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~ |
ae1d397
to
cf0d535
Compare
@wwbmmm why is 1 workflow awaiting approval? |
Because you are first-time contributor. |
src/brpc/stream.cpp
Outdated
@@ -72,6 +74,11 @@ int Stream::Create(const StreamOptions &options, | |||
s->_connected = false; | |||
s->_options = options; | |||
s->_closed = false; | |||
s->_cur_max_buf_size = options.max_buf_size; | |||
if (FLAGS_socket_max_streams_unconsumed_bytes > 0 && options.min_buf_size > 0) { |
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.
此处应使用s->_options.min_buf_size
cf0d535
to
1874f5a
Compare
@wwbmmm ok |
src/brpc/stream.h
Outdated
// The max size of unconsumed data allowed at remote side. | ||
// If |max_buf_size| <= 0, there's no limit of buf size | ||
// default: 2097152 (2M) | ||
int max_buf_size; | ||
size_t max_buf_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.
最好不要改已有的字段吧
而且注释里也写了 <= 0,说明可能是负数
我意思是用max_buf_size的地方判断一下是否>0再用
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.
也行吧,按原来int的逻辑吧。
最好不要改已有的字段吧 而且注释里也写了 <= 0,说明可能是负数 我意思是用max_buf_size的地方判断一下是否>0再用
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.
最好不要改已有的字段吧 而且注释里也写了 <= 0,说明可能是负数 我意思是用max_buf_size的地方判断一下是否>0再用
@wwbmmm 原来==判断改成<=了
1874f5a
to
8d56034
Compare
LGTM |
8d56034
to
66a3542
Compare
66a3542
to
efdfb63
Compare