Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b492cf00
Commit
b492cf00
authored
Jan 07, 2010
by
antirez
Browse files
VM now swaps objects out while loading datasets not fitting into vm-max-memory bytes of RAM
parent
0d7170a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
b492cf00
...
@@ -3178,6 +3178,7 @@ static int rdbLoad(char *filename) {
...
@@ -3178,6 +3178,7 @@ static int rdbLoad(char *filename) {
redisDb *db = server.db+0;
redisDb *db = server.db+0;
char buf[1024];
char buf[1024];
time_t expiretime = -1, now = time(NULL);
time_t expiretime = -1, now = time(NULL);
long long loadedkeys = 0;
fp = fopen(filename,"r");
fp = fopen(filename,"r");
if (!fp) return REDIS_ERR;
if (!fp) return REDIS_ERR;
...
@@ -3235,6 +3236,13 @@ static int rdbLoad(char *filename) {
...
@@ -3235,6 +3236,13 @@ static int rdbLoad(char *filename) {
expiretime = -1;
expiretime = -1;
}
}
keyobj = o = NULL;
keyobj = o = NULL;
/* Handle swapping while loading big datasets when VM is on */
loadedkeys++;
if (server.vm_enabled && (loadedkeys % 5000) == 0) {
while (zmalloc_used_memory() > server.vm_max_memory) {
if (vmSwapOneObject() == REDIS_ERR) break;
}
}
}
}
fclose(fp);
fclose(fp);
return REDIS_OK;
return REDIS_OK;
...
@@ -6417,6 +6425,7 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -6417,6 +6425,7 @@ int loadAppendOnlyFile(char *filename) {
struct redisClient *fakeClient;
struct redisClient *fakeClient;
FILE *fp = fopen(filename,"r");
FILE *fp = fopen(filename,"r");
struct redis_stat sb;
struct redis_stat sb;
unsigned long long loadedkeys = 0;
if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0)
if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0)
return REDIS_ERR;
return REDIS_ERR;
...
@@ -6478,6 +6487,13 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -6478,6 +6487,13 @@ int loadAppendOnlyFile(char *filename) {
/* Clean up, ready for the next command */
/* Clean up, ready for the next command */
for (j = 0; j < argc; j++) decrRefCount(argv[j]);
for (j = 0; j < argc; j++) decrRefCount(argv[j]);
zfree(argv);
zfree(argv);
/* Handle swapping while loading big datasets when VM is on */
loadedkeys++;
if (server.vm_enabled && (loadedkeys % 5000) == 0) {
while (zmalloc_used_memory() > server.vm_max_memory) {
if (vmSwapOneObject() == REDIS_ERR) break;
}
}
}
}
fclose(fp);
fclose(fp);
freeFakeClient(fakeClient);
freeFakeClient(fakeClient);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment