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
ea5350c5ec
commit
8dd16caec8
@ -127,21 +127,9 @@ void receiveChildInfo(void) {
|
||||
int process_type;
|
||||
int on_exit;
|
||||
size_t cow_size;
|
||||
if (readChildInfo(&process_type, &on_exit, &cow_size)) {
|
||||
updateChildInfo(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) {
|
||||
|
||||
/* Drain the pipe and update child info so that we get the final message. */
|
||||
while (readChildInfo(&process_type, &on_exit, &cow_size)) {
|
||||
updateChildInfo(process_type, on_exit, cow_size);
|
||||
}
|
||||
}
|
||||
|
@ -2013,7 +2013,6 @@ void openChildInfoPipe(void);
|
||||
void closeChildInfoPipe(void);
|
||||
void sendChildInfo(int process_type, int on_exit, size_t cow_size);
|
||||
void receiveChildInfo(void);
|
||||
void receiveLastChildInfo(void);
|
||||
|
||||
/* Fork helpers */
|
||||
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) {
|
||||
#if defined(__APPLE__)
|
||||
struct proc_regioninfo pri;
|
||||
if (proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri, PROC_PIDREGIONINFO_SIZE) ==
|
||||
PROC_PIDREGIONINFO_SIZE) {
|
||||
if (!strcmp(field, "Private_Dirty:")) {
|
||||
return (size_t)pri.pri_pages_dirtied * 4096;
|
||||
} else if (!strcmp(field, "Rss:")) {
|
||||
return (size_t)pri.pri_pages_resident * 4096;
|
||||
} else if (!strcmp(field, "AnonHugePages:")) {
|
||||
if (pid == -1) pid = getpid();
|
||||
if (proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri,
|
||||
PROC_PIDREGIONINFO_SIZE) == PROC_PIDREGIONINFO_SIZE)
|
||||
{
|
||||
int pagesize = getpagesize();
|
||||
if (!strcmp(field, "Private_Dirty:")) {
|
||||
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;
|
||||
#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 ""}} {
|
||||
test {Test child sending COW info} {
|
||||
# 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.
|
||||
# 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 loglevel debug
|
||||
|
||||
# populate the db with 10k keys of 4k each
|
||||
set rd [redis_deferring_client 0]
|
||||
@ -247,8 +252,9 @@ start_server {overrides {save ""}} {
|
||||
} else {
|
||||
if {$::verbose} {
|
||||
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
|
||||
@ -265,11 +271,21 @@ start_server {overrides {save ""}} {
|
||||
}
|
||||
|
||||
# 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
|
||||
|
||||
# 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 } {
|
||||
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