forked from redis/redis
-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for module to defrag incremental #372
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
Open
sundb
wants to merge
31
commits into
active-defrag
Choose a base branch
from
incrementail_defrag_module
base: active-defrag
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 7 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
1583d60
Missing --memkeys and --keystats for some options in redis-cli help t…
yveslb 87124a3
Fix wrongly updating fsynced_reploff_pending when appendfsync=everyse…
ShooterIT 662cb2f
Don't send unnecessary PING to replicas (#13790)
ShooterIT d29f04a
Add support for module to defrag incremental
sundb 53c1d99
Fix complaint
sundb 7f5f588
AOF offset info (#13773)
ShooterIT 57807cd
Memory Usage command LIST accuracy fix (#13783)
ofirluzon 0fd9d74
Merge branch 'active-defrag' into incrementail_defrag_module
sundb e260847
Add HGETDEL, HGETEX and HSETEX hash commands (#13798)
tezc 6c202f4
Remove DENYOOM flag from hexpire command (#13800)
tezc 467ddbb
Merge branch 'active-defrag' into incrementail_defrag_module
sundb 6155198
Unify RedisModuleDefragFunc and RedisModuleTypeDefragFunc
sundb e85ebc4
Sync branch DefragRedisModuleDictDict
sundb 98e13b3
Add RedisModule_RegisterDefragFunc2 module api
sundb 4f0f7a7
Cleanup
sundb 0f41e19
Add defragtest_global_strings_pauses to check string pauses
sundb 69879fa
Cleanup
sundb 2e0ff33
defragModuleCtx no longer stores module, which may be unlaoded midway
sundb 9dfcdbb
Add support for both v1 and v2
sundb 61fb33d
Merge branch 'active-defrag' into incrementail_defrag_module
sundb b4f859f
Merge branch 'active-defrag' into incrementail_defrag_module
sundb a64e6cf
Merge branch 'active-defrag' into incrementail_defrag_module
sundb a202a99
Style
sundb 4cbe954
Fix RedisModuleDefragCtx calloc
sundb 051705f
Update src/module.c
sundb c5f91ab
Fix syntax issue in comments of src/module.c (#13802)
yunxiao3 b045fe4
Fix overflow on 32-bit systems when calculating idle time for evictio…
luozongle01 66df58f
Do not send NL if replica client is already closed (#13813)
guybe7 dd40ed1
Merge branch 'active-defrag' into incrementail_defrag_module
sundb 725cd26
Refactor of ActiveDefrag to reduce latencies (#13814)
sundb 0a11110
Merge branch 'unstable' into incrementail_defrag_module
sundb 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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,34 +21,43 @@ unsigned long int datatype_defragged = 0; | |
unsigned long int datatype_raw_defragged = 0; | ||
unsigned long int datatype_resumes = 0; | ||
unsigned long int datatype_wrong_cursor = 0; | ||
unsigned long int global_attempts = 0; | ||
unsigned long int global_strings_attempts = 0; | ||
unsigned long int defrag_started = 0; | ||
unsigned long int defrag_ended = 0; | ||
unsigned long int global_defragged = 0; | ||
unsigned long int global_strings_defragged = 0; | ||
|
||
int global_strings_len = 0; | ||
unsigned long global_strings_len = 0; | ||
RedisModuleString **global_strings = NULL; | ||
|
||
static void createGlobalStrings(RedisModuleCtx *ctx, int count) | ||
static void createGlobalStrings(RedisModuleCtx *ctx, unsigned long count) | ||
{ | ||
global_strings_len = count; | ||
global_strings = RedisModule_Alloc(sizeof(RedisModuleString *) * count); | ||
|
||
for (int i = 0; i < count; i++) { | ||
for (unsigned long i = 0; i < count; i++) { | ||
global_strings[i] = RedisModule_CreateStringFromLongLong(ctx, i); | ||
} | ||
} | ||
|
||
static void defragGlobalStrings(RedisModuleDefragCtx *ctx) | ||
static int defragGlobalStrings(RedisModuleDefragCtx *ctx) | ||
{ | ||
for (int i = 0; i < global_strings_len; i++) { | ||
RedisModuleString *new = RedisModule_DefragRedisModuleString(ctx, global_strings[i]); | ||
global_attempts++; | ||
unsigned long cursor = 0; | ||
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. @oranagra i don't use a global index here, i think it's better to tell module developer another way to use the cursor. |
||
RedisModule_DefragCursorGet(ctx, &cursor); | ||
RedisModule_Assert(cursor < global_strings_len); | ||
for (; cursor < global_strings_len; cursor++) { | ||
RedisModuleString *new = RedisModule_DefragRedisModuleString(ctx, global_strings[cursor]); | ||
global_strings_attempts++; | ||
if (new != NULL) { | ||
global_strings[i] = new; | ||
global_defragged++; | ||
global_strings[cursor] = new; | ||
global_strings_defragged++; | ||
} | ||
|
||
if (RedisModule_DefragShouldStop(ctx)) { | ||
RedisModule_DefragCursorSet(ctx, cursor); | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
static void defragStart(RedisModuleDefragCtx *ctx) { | ||
|
@@ -70,8 +79,8 @@ static void FragInfo(RedisModuleInfoCtx *ctx, int for_crash_report) { | |
RedisModule_InfoAddFieldLongLong(ctx, "datatype_raw_defragged", datatype_raw_defragged); | ||
RedisModule_InfoAddFieldLongLong(ctx, "datatype_resumes", datatype_resumes); | ||
RedisModule_InfoAddFieldLongLong(ctx, "datatype_wrong_cursor", datatype_wrong_cursor); | ||
RedisModule_InfoAddFieldLongLong(ctx, "global_attempts", global_attempts); | ||
RedisModule_InfoAddFieldLongLong(ctx, "global_defragged", global_defragged); | ||
RedisModule_InfoAddFieldLongLong(ctx, "global_strings_attempts", global_strings_attempts); | ||
RedisModule_InfoAddFieldLongLong(ctx, "global_strings_defragged", global_strings_defragged); | ||
RedisModule_InfoAddFieldLongLong(ctx, "defrag_started", defrag_started); | ||
RedisModule_InfoAddFieldLongLong(ctx, "defrag_ended", defrag_ended); | ||
} | ||
|
@@ -99,8 +108,8 @@ static int fragResetStatsCommand(RedisModuleCtx *ctx, RedisModuleString **argv, | |
datatype_raw_defragged = 0; | ||
datatype_resumes = 0; | ||
datatype_wrong_cursor = 0; | ||
global_attempts = 0; | ||
global_defragged = 0; | ||
global_strings_attempts = 0; | ||
global_strings_defragged = 0; | ||
defrag_started = 0; | ||
defrag_ended = 0; | ||
|
||
|
@@ -258,7 +267,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) | |
return REDISMODULE_ERR; | ||
|
||
RedisModule_RegisterInfoFunc(ctx, FragInfo); | ||
RedisModule_RegisterDefragFunc(ctx, defragGlobalStrings); | ||
RedisModule_RegisterDefragFunc2(ctx, defragGlobalStrings); | ||
RedisModule_RegisterDefragCallbacks(ctx, defragStart, defragEnd); | ||
|
||
return REDISMODULE_OK; | ||
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.