Fix last COW INFO report, Skip test on non-linux platforms (#8301)
- the last COW report wasn't always read from the pipe (receiveLastChildInfo wasn't used) - but in fact, there's no reason we won't always try to drain that pipe so i'm unifying receiveLastChildInfo with receiveChildInfo - adjust threshold of the COW test when run in accurate mode - add some prints in case this test fails again - fix indentation, page size, and PID! in MacOS proc info p.s. it seems that pri_pages_dirtied is always 0
This commit is contained in:
parent
db1cc665f4
commit
46729a7404
@ -127,21 +127,9 @@ void receiveChildInfo(void) {
|
|||||||
int process_type;
|
int process_type;
|
||||||
int on_exit;
|
int on_exit;
|
||||||
size_t cow_size;
|
size_t cow_size;
|
||||||
if (readChildInfo(&process_type, &on_exit, &cow_size)) {
|
|
||||||
updateChildInfo(process_type, on_exit, cow_size);
|
/* Drain the pipe and update child info so that we get the final message. */
|
||||||
}
|
while (readChildInfo(&process_type, &on_exit, &cow_size)) {
|
||||||
}
|
|
||||||
|
|
||||||
/* Receive last COW data from child. */
|
|
||||||
void receiveLastChildInfo(void) {
|
|
||||||
if (server.child_info_pipe[0] == -1) return;
|
|
||||||
|
|
||||||
/* Drain the pipe and update child info */
|
|
||||||
int process_type;
|
|
||||||
int on_exit;
|
|
||||||
size_t cow_size;
|
|
||||||
|
|
||||||
while (readChildInfo(&process_type, &on_exit, &cow_size) > 0) {
|
|
||||||
updateChildInfo(process_type, on_exit, cow_size);
|
updateChildInfo(process_type, on_exit, cow_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2013,7 +2013,6 @@ void openChildInfoPipe(void);
|
|||||||
void closeChildInfoPipe(void);
|
void closeChildInfoPipe(void);
|
||||||
void sendChildInfo(int process_type, int on_exit, size_t cow_size);
|
void sendChildInfo(int process_type, int on_exit, size_t cow_size);
|
||||||
void receiveChildInfo(void);
|
void receiveChildInfo(void);
|
||||||
void receiveLastChildInfo(void);
|
|
||||||
|
|
||||||
/* Fork helpers */
|
/* Fork helpers */
|
||||||
int redisFork(int type);
|
int redisFork(int type);
|
||||||
|
@ -580,15 +580,18 @@ size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) {
|
|||||||
size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) {
|
size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) {
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
struct proc_regioninfo pri;
|
struct proc_regioninfo pri;
|
||||||
if (proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri, PROC_PIDREGIONINFO_SIZE) ==
|
if (pid == -1) pid = getpid();
|
||||||
PROC_PIDREGIONINFO_SIZE) {
|
if (proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri,
|
||||||
if (!strcmp(field, "Private_Dirty:")) {
|
PROC_PIDREGIONINFO_SIZE) == PROC_PIDREGIONINFO_SIZE)
|
||||||
return (size_t)pri.pri_pages_dirtied * 4096;
|
{
|
||||||
} else if (!strcmp(field, "Rss:")) {
|
int pagesize = getpagesize();
|
||||||
return (size_t)pri.pri_pages_resident * 4096;
|
if (!strcmp(field, "Private_Dirty:")) {
|
||||||
} else if (!strcmp(field, "AnonHugePages:")) {
|
return (size_t)pri.pri_pages_dirtied * pagesize;
|
||||||
|
} else if (!strcmp(field, "Rss:")) {
|
||||||
|
return (size_t)pri.pri_pages_resident * pagesize;
|
||||||
|
} else if (!strcmp(field, "AnonHugePages:")) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -199,6 +199,10 @@ test {client freed during loading} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Our COW metrics (Private_Dirty) work only on Linux
|
||||||
|
set system_name [string tolower [exec uname -s]]
|
||||||
|
if {$system_name eq {linux}} {
|
||||||
|
|
||||||
start_server {overrides {save ""}} {
|
start_server {overrides {save ""}} {
|
||||||
test {Test child sending COW info} {
|
test {Test child sending COW info} {
|
||||||
# make sure that rdb_last_cow_size and current_cow_size are zero (the test using new server),
|
# make sure that rdb_last_cow_size and current_cow_size are zero (the test using new server),
|
||||||
@ -209,6 +213,7 @@ start_server {overrides {save ""}} {
|
|||||||
# using a 200us delay, the bgsave is empirically taking about 10 seconds.
|
# using a 200us delay, the bgsave is empirically taking about 10 seconds.
|
||||||
# we need it to take more than some 5 seconds, since redis only report COW once a second.
|
# we need it to take more than some 5 seconds, since redis only report COW once a second.
|
||||||
r config set rdb-key-save-delay 200
|
r config set rdb-key-save-delay 200
|
||||||
|
r config set loglevel debug
|
||||||
|
|
||||||
# populate the db with 10k keys of 4k each
|
# populate the db with 10k keys of 4k each
|
||||||
set rd [redis_deferring_client 0]
|
set rd [redis_deferring_client 0]
|
||||||
@ -247,8 +252,9 @@ start_server {overrides {save ""}} {
|
|||||||
} else {
|
} else {
|
||||||
if {$::verbose} {
|
if {$::verbose} {
|
||||||
puts "COW info on fail: [s current_cow_size]"
|
puts "COW info on fail: [s current_cow_size]"
|
||||||
|
puts [exec tail -n 100 < [srv 0 stdout]]
|
||||||
}
|
}
|
||||||
fail "COW info didn't report"
|
fail "COW info wasn't reported"
|
||||||
}
|
}
|
||||||
|
|
||||||
# for no accurate, stop after 2 iterations
|
# for no accurate, stop after 2 iterations
|
||||||
@ -265,11 +271,21 @@ start_server {overrides {save ""}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# make sure we saw report of current_cow_size
|
# make sure we saw report of current_cow_size
|
||||||
|
if {$iteration < 2 && $::verbose} {
|
||||||
|
puts [exec tail -n 100 < [srv 0 stdout]]
|
||||||
|
}
|
||||||
assert_morethan_equal $iteration 2
|
assert_morethan_equal $iteration 2
|
||||||
|
|
||||||
# if bgsave completed, check that rdb_last_cow_size value is at least as last rdb_active_cow_size.
|
# if bgsave completed, check that rdb_last_cow_size (fork exit report)
|
||||||
|
# is at least 90% of last rdb_active_cow_size.
|
||||||
if { [s rdb_bgsave_in_progress] == 0 } {
|
if { [s rdb_bgsave_in_progress] == 0 } {
|
||||||
assert_morethan_equal [s rdb_last_cow_size] $cow_size
|
set final_cow [s rdb_last_cow_size]
|
||||||
|
set cow_size [expr $cow_size * 0.9]
|
||||||
|
if {$final_cow < $cow_size && $::verbose} {
|
||||||
|
puts [exec tail -n 100 < [srv 0 stdout]]
|
||||||
|
}
|
||||||
|
assert_morethan_equal $final_cow $cow_size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} ;# system_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user