-
Notifications
You must be signed in to change notification settings - Fork 58
feat: make the block size configurable for mutation logs #889
base: master
Are you sure you want to change the base?
Conversation
src/common/replication_common.cpp
Outdated
@@ -348,6 +350,10 @@ void replication_options::initialize() | |||
"log_private_reserve_max_time_seconds", | |||
log_private_reserve_max_time_seconds, | |||
"max time in seconds of useless private log to be reserved"); | |||
log_private_block_bytes = dsn_config_get_value_int64("replication", |
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.
Now a new gflag like config defination is introduced, you can use it instead.
See
rdsn/include/dsn/utility/flags.h
Line 56 in 552169e
#define DSN_DECLARE_int64(name) DSN_DECLARE_VARIABLE(int64_t, name) |
src/common/replication_common.cpp
Outdated
log_private_block_bytes = dsn_config_get_value_int64("replication", | ||
"log_private_block_bytes", | ||
log_private_block_bytes, | ||
"block size by bytes for private log"); |
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.
'in bytes' ?
src/replica/log_file.cpp
Outdated
@@ -35,7 +35,8 @@ namespace dsn { | |||
namespace replication { | |||
|
|||
log_file::~log_file() { close(); } | |||
/*static */ log_file_ptr log_file::open_read(const char *path, /*out*/ error_code &err) | |||
/*static */ log_file_ptr | |||
log_file::open_read(const char *path, /*out*/ error_code &err, size_t block_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.
If you using the new FLAGS_XXX instead, then these parameters are not needed to pass everywhere.
Can you add some test results about your changes? Like the relationship between configuration and memory |
Hi, empiredan~ I notice that you would like to make block size configurable to |
@Smityz Yeah, it's necessary to provide some test results that show how much we can limit memory, though we've not make some formal tests. I'll try to make some ones. |
@hycdong Great, I'm also interested in the memory related problems, we can discuss about this one. Since the original description for this PR is too simple, I'll explain some more. Since the memory of our machine is very limited (also deployed with many other services), we'll try our best to save memory. Actually this PR is added in our internal version more than a year ago. At that time, I observed from the memory profile by tcmalloc that a lot of memory had been consumed by reading plog files into the caches. Therefore, I make the buffer size for plog configurable to limit memory consumed, which is tuned from 1MB to 256KB. As for this PR, I also make the buffer size for slog configurable. Now there is a problem we can discuss. According to the suggestion from @acelyc111 , we can use FLAGS_XXX to denote the buffer size for slog and plog. However, besides the slog and plog, some other components, such as mutation log tools and unit tests, are operating the underlying log_file class, which will lead to a deep call chain to pass the parameter of block size. This will also result in a lot of modifications of source files. To some extent maybe a default block size will alleviate this problem, but it seems not a graceful method. Have some advices about this problem, or this PR ? Thanks ! |
Thanks for your detailed explanation~ I agree that make the buffer size for slog configurable is a good job~
|
@hycdong Good idea ! Thanks for suggestion ! Does this mean we use a single config |
Sorry for long-time no-reply. Yes, you can use |
We can divide all the related classes into several levels, where the lowest level is
Based on the 2 points discussed above, we can draw some conclusions. Firstly, we should import some configuration items as below:
If Secondly, use By the way, some bugs are found in @Smityz @hycdong @acelyc111 please feel free to review the updated conclusions and codes. If this is feasible, later I'll add some unit tests for this. |
The block size used to read the files of mutation logs should be configurable to limit the memory consumed by rDSN, with
log_private_block_bytes
specified for private logs andlog_shared_block_bytes
for shared logs.The default block size is still 1MB, as it's used before.