diff options
author | antirez <antirez@gmail.com> | 2020-01-13 12:50:26 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2020-01-13 12:50:26 +0100 |
commit | a8c912ead65e85b5ce3dae936320e77e047df9c9 (patch) | |
tree | 24fc26ae8d0090678a2b40d9aa792f9c50592a1d | |
parent | 24896427fc88e944d466874954503b1100263b65 (diff) | |
download | redis-a8c912ead65e85b5ce3dae936320e77e047df9c9.tar.gz |
A few comments about main thread serving I/O as well.
Related to #6110.
-rw-r--r-- | src/networking.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c index f1a6b9910..96ab8e592 100644 --- a/src/networking.c +++ b/src/networking.c @@ -2656,6 +2656,10 @@ pthread_mutex_t io_threads_mutex[IO_THREADS_MAX_NUM]; _Atomic unsigned long io_threads_pending[IO_THREADS_MAX_NUM]; int io_threads_active; /* Are the threads currently spinning waiting I/O? */ int io_threads_op; /* IO_THREADS_OP_WRITE or IO_THREADS_OP_READ. */ + +/* This is the list of clients each thread will serve when threaded I/O is + * used. We spawn N threads, and the N+1 list is used for the clients that + * are processed by the main thread itself (this is why ther is "+1"). */ list *io_threads_list[IO_THREADS_MAX_NUM+1]; void *IOThreadMain(void *myid) { @@ -2729,7 +2733,7 @@ void initThreadedIO(void) { } io_threads[i] = tid; } - io_threads_list[server.io_threads_num] = listCreate(); + io_threads_list[server.io_threads_num] = listCreate(); /* For main thread */ } void startThreadedIO(void) { @@ -2814,6 +2818,7 @@ int handleClientsWithPendingWritesUsingThreads(void) { io_threads_pending[j] = count; } + /* Also use the main thread to process a slide of clients. */ listRewind(io_threads_list[server.io_threads_num],&li); while((ln = listNext(&li))) { client *c = listNodeValue(ln); @@ -2898,6 +2903,7 @@ int handleClientsWithPendingReadsUsingThreads(void) { io_threads_pending[j] = count; } + /* Also use the main thread to process a slide of clients. */ listRewind(io_threads_list[server.io_threads_num],&li); while((ln = listNext(&li))) { client *c = listNodeValue(ln); |