-
Notifications
You must be signed in to change notification settings - Fork 220
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
Optimize the configure options. #269
Open
ly1217
wants to merge
1
commit into
master
Choose a base branch
from
optimize_configure_options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -612,6 +612,12 @@ chunking_worker (gpointer vdata, gpointer user_data) | |
int fd = -1; | ||
ssize_t n; | ||
int idx; | ||
gint64 fixed_block_size; | ||
int fixed_block_size_mb; | ||
char *group = g_key_file_has_group (seaf->config, "fileserver") ? "fileserver" : "httpserver"; | ||
|
||
fixed_block_size_mb = seaf_cfg_manager_get_config_int (seaf->cfg_mgr, group, "fixed_block_size"); | ||
fixed_block_size = fixed_block_size_mb * ((gint64)1 << 20); | ||
|
||
chunk->block_buf = g_new0 (char, chunk->len); | ||
if (!chunk->block_buf) { | ||
|
@@ -646,7 +652,7 @@ chunking_worker (gpointer vdata, gpointer user_data) | |
if (chunk->result < 0) | ||
goto out; | ||
|
||
idx = chunk->offset / seaf->http_server->fixed_block_size; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 所有类似 seaf->http_server->fixed_block_size 这样的配置变量,都应该从结构体中删除,这样才能保证没有漏改的代码。 |
||
idx = chunk->offset / fixed_block_size; | ||
memcpy (data->blk_sha1s + idx * CHECKSUM_LENGTH, chunk->checksum, CHECKSUM_LENGTH); | ||
|
||
out: | ||
|
@@ -673,8 +679,22 @@ split_file_to_block (const char *repo_id, | |
int n_pending = 0; | ||
CDCDescriptor *chunk; | ||
int ret = 0; | ||
int fixed_block_size_mb; | ||
int max_indexing_threads; | ||
gint64 fixed_block_size; | ||
char *group = g_key_file_has_group (seaf->config, "fileserver") ? "fileserver" : "httpserver"; | ||
|
||
fixed_block_size_mb = seaf_cfg_manager_get_config_int (seaf->cfg_mgr, | ||
group, | ||
"fixed_block_size"); | ||
fixed_block_size = fixed_block_size_mb * ((gint64)1 << 20); | ||
|
||
max_indexing_threads = seaf_cfg_manager_get_config_int (seaf->cfg_mgr, | ||
group, | ||
"max_indexing_threads"); | ||
|
||
n_blocks = (file_size + fixed_block_size - 1) / fixed_block_size; | ||
|
||
n_blocks = (file_size + seaf->http_server->fixed_block_size - 1) / seaf->http_server->fixed_block_size; | ||
block_sha1s = g_new0 (uint8_t, n_blocks * CHECKSUM_LENGTH); | ||
if (!block_sha1s) { | ||
seaf_warning ("Failed to allocate block_sha1s.\n"); | ||
|
@@ -694,7 +714,7 @@ split_file_to_block (const char *repo_id, | |
data.finished_tasks = finished_tasks; | ||
|
||
tpool = g_thread_pool_new (chunking_worker, &data, | ||
seaf->http_server->max_indexing_threads, FALSE, NULL); | ||
max_indexing_threads, FALSE, NULL); | ||
if (!tpool) { | ||
seaf_warning ("Failed to allocate thread pool\n"); | ||
ret = -1; | ||
|
@@ -705,7 +725,7 @@ split_file_to_block (const char *repo_id, | |
guint64 len; | ||
guint64 left = (guint64)file_size; | ||
while (left > 0) { | ||
len = ((left >= seaf->http_server->fixed_block_size) ? seaf->http_server->fixed_block_size : left); | ||
len = ((left >= fixed_block_size) ? fixed_block_size : left); | ||
|
||
chunk = g_new0 (CDCDescriptor, 1); | ||
chunk->offset = offset; | ||
|
@@ -725,7 +745,7 @@ split_file_to_block (const char *repo_id, | |
goto out; | ||
} | ||
if (indexed) | ||
*indexed += seaf->http_server->fixed_block_size; | ||
*indexed += fixed_block_size; | ||
|
||
if ((--n_pending) <= 0) { | ||
if (indexed) | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.
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.
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.
这个结构体应该只包含一个 SeafCfgMgrPriv 的指针,然后 Priv 这个机构在 .c 文件中定义。一般不要把内部的数据机构暴露在头文件中。