summaryrefslogtreecommitdiff
path: root/src/rio.c
diff options
context:
space:
mode:
authorDarrenJiang13 <yjjiang1996@163.com>2022-05-31 13:07:33 +0800
committerGitHub <noreply@github.com>2022-05-31 08:07:33 +0300
commitbb1de082eac26d5242733eb0b40959bd9de2e15b (patch)
treec3e1125652b263c3fefea1ea0eeca33f686a12bb /src/rio.c
parent4065b4f27efc539b86beb63829bc148a02adecb1 (diff)
downloadredis-bb1de082eac26d5242733eb0b40959bd9de2e15b.tar.gz
Adds isolated netstats for replication. (#10062)
The amount of `server.stat_net_output_bytes/server.stat_net_input_bytes` is actually the sum of replication flow and users' data flow. It may cause confusions like this: "Why does my server get such a large output_bytes while I am doing nothing? ". After discussions and revisions, now here is the change about what this PR brings (final version before merge): - 2 server variables to count the network bytes during replication, including fullsync and propagate bytes. - `server.stat_net_repl_output_bytes`/`server.stat_net_repl_input_bytes` - 3 info fields to print the input and output of repl bytes and instantaneous value of total repl bytes. - `total_net_repl_input_bytes` / `total_net_repl_output_bytes` - `instantaneous_repl_total_kbps` - 1 new API `rioCheckType()` to check the type of rio. So we can use this to distinguish between diskless and diskbased replication - 2 new counting items to keep network statistics consistent between master and slave - rdb portion during diskless replica. in `rdbLoadProgressCallback()` - first line of the full sync payload. in `readSyncBulkPayload()` Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/rio.c')
-rw-r--r--src/rio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rio.c b/src/rio.c
index f99913152..bcda3767b 100644
--- a/src/rio.c
+++ b/src/rio.c
@@ -438,6 +438,20 @@ void rioSetAutoSync(rio *r, off_t bytes) {
r->io.file.autosync = bytes;
}
+/* Check the type of rio. */
+uint8_t rioCheckType(rio *r) {
+ if (r->read == rioFileRead) {
+ return RIO_TYPE_FILE;
+ } else if (r->read == rioBufferRead) {
+ return RIO_TYPE_BUFFER;
+ } else if (r->read == rioConnRead) {
+ return RIO_TYPE_CONN;
+ } else {
+ /* r->read == rioFdRead */
+ return RIO_TYPE_FD;
+ }
+}
+
/* --------------------------- Higher level interface --------------------------
*
* The following higher level functions use lower level rio.c functions to help