update butil::default_block_size when rdma_recv_block_type is set#3303
Open
randomkang wants to merge 4 commits into
Open
update butil::default_block_size when rdma_recv_block_type is set#3303randomkang wants to merge 4 commits into
randomkang wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
src/brpc/rdma/rdma_endpoint.cpp:1634
- GlobalInitialize() stores the result of
GetRdmaBlockSize() - IOBUF_BLOCK_HEADER_LENinto uint32_t. If GetRdmaBlockSize() signals errors via size_t(-1) (or returns a value smaller than the header), this will underflow/wrap and the<= 0check won’t catch it. Validate the GetRdmaBlockSize() result before subtraction/cast (and ensure the type can represent errors).
g_rdma_recv_block_size = GetRdmaBlockSize() - IOBUF_BLOCK_HEADER_LEN;
if (g_rdma_recv_block_size <= 0) {
LOG(ERROR) << "rdma_recv_block_type incorrect "
<< "(valid value: default/large/huge)";
errno = EINVAL;
return -1;
Comment on lines
329
to
331
| if (ExtendBlockPool(FLAGS_rdma_memory_pool_initial_size_mb, | ||
| BLOCK_DEFAULT) != NULL) { | ||
| GetRdmaBlockType()) != NULL) { | ||
| return true; |
| } else { | ||
| LOG(ERROR) << "rdma_recv_block_type incorrect " | ||
| << "(valid value: default/large/huge)"; | ||
| return -1; |
Comment on lines
97
to
+105
| // Return the block size of given block type | ||
| // type=1: BLOCK_DEFAULT(8KB) | ||
| // type=2: BLOCK_LARGE(64KB) | ||
| // type=3: BLOCK_HUGE(2MB) | ||
| size_t GetBlockSize(int type); | ||
|
|
||
| size_t GetRdmaBlockSize(); | ||
|
|
||
| int GetRdmaBlockType(); |
Comment on lines
+45
to
+56
| static size_t default_block_size = 8192; | ||
|
|
||
| size_t GetDefaultBlockSize() { | ||
| return default_block_size; | ||
| } | ||
|
|
||
| void SetDefaultBlockSize(size_t block_size) { | ||
| if (block_size / 4096 * 4096 != block_size) { | ||
| LOG(FATAL) << "block_size " << block_size << " should be multiply of 4096!!!"; | ||
| } | ||
| LOG(INFO) << "Update default_block_size from " << default_block_size << " to " << block_size; | ||
| default_block_size = block_size; |
Comment on lines
+52
to
+54
| if (block_size / 4096 * 4096 != block_size) { | ||
| LOG(FATAL) << "block_size " << block_size << " should be multiply of 4096!!!"; | ||
| } |
Comment on lines
+55
to
+58
| size_t GetDefaultBlockSize(); | ||
|
|
||
| void SetDefaultBlockSize(size_t block_size); | ||
|
|
Comment on lines
552
to
555
| // Initialize RDMA memory pool (block_pool) | ||
| butil::SetDefaultBlockSize(GetRdmaBlockSize()); | ||
| if (!InitBlockPool(RdmaRegisterMemory)) { | ||
| PLOG(ERROR) << "Fail to initialize RDMA memory pool"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: 3301
Problem Summary:
What is changed and the side effects?
Changed:
Side effects:
The bandwith of rdma perf will be increased 10%(in my case, from 21GB/s to 23GB/s ).
Check List: