Look up in $GOROOT/src/runtime/slice.go:makeslice.
append
https://stackoverflow.com/a/33405824/13133551
slicing
The length is the number of elements referred to by the slice. The capacity is the number of elements in the underlying array (beginning at the element referred to by the slice pointer).
copy
Look up in $GOROOT/src/runtime/slice.go:slicecopy.
The copy function supports copying between slices of different lengths (it will copy only up to the smaller number of elements). In addition, copy can handle source and destination slices that share the same underlying array, handling overlapping slices correctly.
funcsliceCopy() { logger.Infof("in sliceCopy") s := make([]int, 0) for i := 0; i < 10; i++ { s = append(s, i) }
c := make([]int, 0) copy(c, s) logger.Infof("c: %v", c)
c = make([]int, 5) copy(c, s) logger.Infof("c: %v", c)
c = make([]int, 15) copy(c, s) logger.Infof("c: %v", c)
c = make([]int, 5, 20) copy(c, s) logger.Infof("c: %v", c)
c[0] = 256 logger.Infof("c: %v, s: %v", c, s) }
funcsliceAppend() { logger.Infof("in sliceAppend") s := make([]int, 0) for i := 0; i < 10; i++ { s = append(s, i) logger.Infof("after appending: %v, len(s): %v, cap(s): %v", i, len(s), cap(s)) } for i := 0; i < 10; i++ { l := len(s) c := cap(s) after := append(s, i) if l == c { assertPanic(&s[0] != &after[0]) assertPanic(s[0] == after[0])
$ ./wait & [1] 7523 Father PID is 7523 Child PID is 7525 time: 1577156913 time: 1577156914 time: 1577156915 time: 1577156916 $ kill 7525 w: 7525, WIFEXITED: 0, WIFSIGNALED: 1, WIFSTOPPED: 0, WIFCONTINUED: 0 killed by signal 15
$ ./wait --handle 15 Father PID is 7566 Child PID is 7567 time: 1577156938 time: 1577156939 time: 1577156940 time: 1577156941 $ kill 7567 signal num: 15 time: 1577156941 time: 1577156942 $ kill -KILL 7567 w: 7567, WIFEXITED: 0, WIFSIGNALED: 1, WIFSTOPPED: 0, WIFCONTINUED: 0 killed by signal 9
1 2 3 4 5 6 7 8 9 10 11 12 13
$ ./wait --divide-zero Child PID is 7744 Father PID is 7743 w: 7744, WIFEXITED: 0, WIFSIGNALED: 1, WIFSTOPPED: 0, WIFCONTINUED: 0 killed by signal 8
$ ./wait --divide-zero --handle 8 Father PID is 7716 Child PID is 7717 signal num: 8 signal num: 8 signal num: 8 ......
1 2 3 4 5 6 7 8 9 10 11 12
$ ./wait --invalid-memory Father PID is 8085 Child PID is 8086 w: 8086, WIFEXITED: 0, WIFSIGNALED: 1, WIFSTOPPED: 0, WIFCONTINUED: 0 killed by signal 11
$ ./wait --invalid-memory --handle 11 Father PID is 8432 Child PID is 8433 signal num: 11 signal num: 11 ......
/* Objects encoding. Some kind of objects like Strings and Hashes can be * internally represented in multiple ways. The 'encoding' field of the object * is set to one of this fields for this object. */ #define REDIS_ENCODING_RAW 0 /* Raw representation */ #define REDIS_ENCODING_INT 1 /* Encoded as integer */ #define REDIS_ENCODING_HT 2 /* Encoded as hash table */ #define REDIS_ENCODING_ZIPMAP 3 /* Encoded as zipmap */ #define REDIS_ENCODING_LINKEDLIST 4 /* Encoded as regular linked list */ #define REDIS_ENCODING_ZIPLIST 5 /* Encoded as ziplist */ #define REDIS_ENCODING_INTSET 6 /* Encoded as intset */ #define REDIS_ENCODING_SKIPLIST 7 /* Encoded as skiplist */ #define REDIS_ENCODING_EMBSTR 8 /* Embedded sds string encoding */
typedefstructredisObject { unsigned type:4; unsigned encoding:4; unsigned lru:REDIS_LRU_BITS; /* lru time (relative to server.lruclock) */ int refcount; void *ptr; } robj;
/* Append the specified binary-safe string pointed by 't' of 'len' bytes to the * end of the specified sds string 's'. * * After the call, the passed sds string is no longer valid and all the * references must be substituted with the new pointer returned by the call. */ sds sdscatlen(sds s, constvoid *t, size_t len){ structsdshdr *sh; size_t curlen = sdslen(s);
s = sdsMakeRoomFor(s,len); if (s == NULL) returnNULL; sh = (void*) (s-(sizeof(struct sdshdr))); memcpy(s+curlen, t, len); sh->len = curlen+len; sh->free = sh->free-len; s[curlen+len] = '\0'; return s; }
/* Append the specified null termianted C string to the sds string 's'. * * After the call, the passed sds string is no longer valid and all the * references must be substituted with the new pointer returned by the call. */ sds sdscat(sds s, constchar *t){ returnsdscatlen(s, t, strlen(t)); }
/* This is our hash table structure. Every dictionary has two of this as we * implement incremental rehashing, for the old to the new table. */ typedefstructdictht { dictEntry **table; unsignedlong size; unsignedlong sizemask; unsignedlong used; } dictht;
typedefstructdict { dictType *type; void *privdata; dictht ht[2]; long rehashidx; /* rehashing not in progress if rehashidx == -1 */ int iterators; /* number of iterators currently running */ } dict;
/* Add an element to the target hash table */ intdictAdd(dict *d, void *key, void *val) { dictEntry *entry = dictAddRaw(d,key);
if (!entry) return DICT_ERR; dictSetVal(d, entry, val); return DICT_OK; }
/* Low level add. This function adds the entry but instead of setting * a value returns the dictEntry structure to the user, that will make * sure to fill the value field as he wishes. * * This function is also directly exposed to the user API to be called * mainly in order to store non-pointers inside the hash value, example: * * entry = dictAddRaw(dict,mykey); * if (entry != NULL) dictSetSignedIntegerVal(entry,1000); * * Return values: * * If key already exists NULL is returned. * If key was added, the hash entry is returned to be manipulated by the caller. */ dictEntry *dictAddRaw(dict *d, void *key) { int index; dictEntry *entry; dictht *ht;
if (dictIsRehashing(d)) _dictRehashStep(d);
/* Get the index of the new element, or -1 if * the element already exists. */ if ((index = _dictKeyIndex(d, key)) == -1) returnNULL;
/* Allocate the memory and store the new entry */ ht = dictIsRehashing(d) ? &d->ht[1] : &d->ht[0]; entry = zmalloc(sizeof(*entry)); entry->next = ht->table[index]; ht->table[index] = entry; ht->used++;
/* Set the hash entry fields. */ dictSetKey(d, entry, key); return entry; }
if (d->ht[0].size == 0) returnNULL; /* We don't have a table at all */ if (dictIsRehashing(d)) _dictRehashStep(d); h = dictHashKey(d, key); for (table = 0; table <= 1; table++) { idx = h & d->ht[table].sizemask; he = d->ht[table].table[idx]; while(he) { if (dictCompareKeys(d, key, he->key)) return he; he = he->next; } if (!dictIsRehashing(d)) returnNULL; } returnNULL; }
A Request/Response server can be implemented so that it is able to process new requests even if the client didn't already read the old responses. This way it is possible to send multiple commands to the server without waiting for the replies at all, and finally read the replies in a single step.
This is called pipelining, and is a technique widely in use since many decades. For instance many POP3 protocol implementations already supported this feature, dramatically speeding up the process of downloading new emails from the server.
Redis has supported pipelining since the very early days, so whatever version you are running, you can use pipelining with Redis. This is an example using the raw netcat utility:
Poll and handle: START Fd: 5 is readable 13021:M 12 Dec 17:44:44.657 - Accepted 127.0.0.1:57151 Create file event on fd: 6, mask: readable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:44:44.657 - readQueryFromClient fd: 6, nread: 144 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is writeable 13021:M 12 Dec 17:44:44.658 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:44:45.638 - readQueryFromClient fd: 6, nread: 0 13021:M 12 Dec 17:44:45.638 - Client closed connection Delete file event on fd: 6, mask: readable Poll and handle: END
Wireshark抓包的结果:
Python实现pipeline调用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# coding: utf-8
import redis
defmain(): client = redis.Redis(host='localhost', port=6379) pipe = client.pipeline(transaction=False) for i inrange(16 * 1024): pipe.set(i, i) pipe.execute()
Poll and handle: START Fd: 5 is readable 13021:M 12 Dec 17:47:02.791 - Accepted 127.0.0.1:57168 Create file event on fd: 6, mask: readable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.001 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.003 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.004 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.004 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.005 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.005 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.006 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.007 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.008 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.008 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.010 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.011 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.011 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.012 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.013 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.013 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.014 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.015 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.016 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.017 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.017 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.018 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.018 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.019 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.019 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.021 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.022 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.022 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.024 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.025 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.025 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.026 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.028 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.028 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.029 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.033 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.033 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.034 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.035 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.035 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.037 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.038 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.038 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.039 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.040 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.040 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.042 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.042 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.042 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.043 - readQueryFromClient fd: 6, nread: 10548 Fd: 6 is writeable 13021:M 12 Dec 17:47:03.044 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13021:M 12 Dec 17:47:03.108 - readQueryFromClient fd: 6, nread: 0 13021:M 12 Dec 17:47:03.108 - Client closed connection Delete file event on fd: 6, mask: readable Poll and handle: END
Poll and handle: START Fd: 5 is readable 13596:M 12 Dec 18:05:49.267 - Accepted 127.0.0.1:57368 Create file event on fd: 6, mask: readable Poll and handle: END Poll and handle: START Fd: 5 is readable 13596:M 12 Dec 18:05:49.269 - Accepted 127.0.0.1:57369 Create file event on fd: 7, mask: readable Poll and handle: END 13596:M 12 Dec 18:05:53.103 - 2 clients connected (0 slaves), 993008 bytes in use 13596:M 12 Dec 18:05:58.237 - 2 clients connected (0 slaves), 993008 bytes in use 13596:M 12 Dec 18:06:03.371 - 2 clients connected (0 slaves), 993008 bytes in use 13596:M 12 Dec 18:06:08.513 - 2 clients connected (0 slaves), 993008 bytes in use Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.131 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.134 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13596:M 12 Dec 18:06:09.134 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.134 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.135 - readQueryFromClient fd: 6, nread: 16384 Fd: 6 is writeable 13596:M 12 Dec 18:06:09.136 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END ................................ Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.283 - readQueryFromClient fd: 6, nread: 16384 Fd: 7 is readable 13596:M 12 Dec 18:06:09.284 - readQueryFromClient fd: 7, nread: 16384 Fd: 6 is writeable 13596:M 12 Dec 18:06:09.285 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Fd: 7 is writeable 13596:M 12 Dec 18:06:09.285 - try sendReplyToClient to fd: 7 Delete file event on fd: 7, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.285 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Fd: 7 is readable 13596:M 12 Dec 18:06:09.285 - readQueryFromClient fd: 7, nread: 16384 Create file event on fd: 7, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.286 - readQueryFromClient fd: 6, nread: 16384 Fd: 7 is readable 13596:M 12 Dec 18:06:09.287 - readQueryFromClient fd: 7, nread: 16384 Fd: 6 is writeable 13596:M 12 Dec 18:06:09.287 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Fd: 7 is writeable 13596:M 12 Dec 18:06:09.287 - try sendReplyToClient to fd: 7 Delete file event on fd: 7, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.288 - readQueryFromClient fd: 6, nread: 16384 Create file event on fd: 6, mask: writeable Fd: 7 is readable 13596:M 12 Dec 18:06:09.288 - readQueryFromClient fd: 7, nread: 16384 Create file event on fd: 7, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:09.289 - readQueryFromClient fd: 6, nread: 16384 Fd: 7 is readable 13596:M 12 Dec 18:06:09.290 - readQueryFromClient fd: 7, nread: 16384 Fd: 6 is writeable 13596:M 12 Dec 18:06:09.291 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Fd: 7 is writeable 13596:M 12 Dec 18:06:09.291 - try sendReplyToClient to fd: 7 Delete file event on fd: 7, mask: writeable Poll and handle: END ................................ Poll and handle: START Fd: 6 is writeable 13596:M 12 Dec 18:06:19.984 - try sendReplyToClient to fd: 6 13596:M 12 Dec 18:06:19.984 - sendReplyToClient EAGAIN, fd: 6 Poll and handle: END Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:20.121 - try sendReplyToClient to fd: 7 Poll and handle: END Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:20.122 - try sendReplyToClient to fd: 7 Poll and handle: END Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:20.122 - try sendReplyToClient to fd: 7 Poll and handle: END Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:20.122 - try sendReplyToClient to fd: 7 13596:M 12 Dec 18:06:20.122 - sendReplyToClient EAGAIN, fd: 7 Poll and handle: END ................................ Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:23.854 - try sendReplyToClient to fd: 7 13596:M 12 Dec 18:06:23.854 - sendReplyToClient EAGAIN, fd: 7 Poll and handle: END Poll and handle: START Fd: 6 is writeable 13596:M 12 Dec 18:06:24.085 - try sendReplyToClient to fd: 6 Poll and handle: END Poll and handle: START Fd: 6 is writeable 13596:M 12 Dec 18:06:24.085 - try sendReplyToClient to fd: 6 Delete file event on fd: 6, mask: writeable Poll and handle: END Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:24.192 - try sendReplyToClient to fd: 7 Poll and handle: END Poll and handle: START Fd: 7 is writeable 13596:M 12 Dec 18:06:24.192 - try sendReplyToClient to fd: 7 Delete file event on fd: 7, mask: writeable Poll and handle: END Poll and handle: START Fd: 6 is readable 13596:M 12 Dec 18:06:26.373 - readQueryFromClient fd: 6, nread: 0 13596:M 12 Dec 18:06:26.373 - Client closed connection Delete file event on fd: 6, mask: readable Poll and handle: END Poll and handle: START Fd: 7 is readable 13596:M 12 Dec 18:06:26.510 - readQueryFromClient fd: 7, nread: 0 13596:M 12 Dec 18:06:26.510 - Client closed connection Delete file event on fd: 7, mask: readable Poll and handle: END
used_memory_rss在linux中是通过读/proc/{pid}/stat这个文件的第24个字段rss得到number of pages the process in real memory然后再乘以sysconf(_SC_PAGESIZE)实现的。sysconf(_SC_PAGESIZE)表示Size of a page in bytes。
used_memory_peakRecord the max memory used since the server was started.