mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-22990 Threadpool : Optimize network/named pipe IO for Windows
This patch reduces the overhead of system calls prior to a query, for threadpool. Previously, 3 system calls were done 1. WSARecv() to get notification of input data from client, asynchronous equivalent of select() in one-thread-per-connection 2. recv(4 bytes) - reading packet header length 3. recv(packet payload) Now there will be usually, just WSARecv(), which pre-reads user data into a buffer, so we spared 2 syscalls Profiler shows the most expensive call WSARecv(16%CPU) becomes 4% CPU, after the patch, benchmark results (network heavy ones like point-select) improve by ~20% The buffer management was rather carefully done to keep buffers together, as Windows would keeps the pages pinned in memory for the duration of async calls. At most 1MB memory is used for the buffers, and overhead per-connection is only 256 bytes, which should cover most of the uses. SSL does not yet use the optmization, so far it does not properly use VIO for reads and writes. Neither one-thread-per-connection would get any benefit, but that should be fine, it is not even default on Windows.
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include "threadpool_winsockets.h"
|
||||
/* AIX may define this, too ?*/
|
||||
#define HAVE_IOCP
|
||||
#endif
|
||||
@ -75,11 +76,11 @@ struct TP_connection_generic :public TP_connection
|
||||
TP_connection_generic(CONNECT* c);
|
||||
~TP_connection_generic();
|
||||
|
||||
virtual int init() { return 0; };
|
||||
virtual void set_io_timeout(int sec);
|
||||
virtual int start_io();
|
||||
virtual void wait_begin(int type);
|
||||
virtual void wait_end();
|
||||
int init() override { return 0; }
|
||||
void set_io_timeout(int sec) override;
|
||||
int start_io() override;
|
||||
void wait_begin(int type) override;
|
||||
void wait_end() override;
|
||||
|
||||
thread_group_t* thread_group;
|
||||
TP_connection_generic* next_in_queue;
|
||||
@ -89,12 +90,13 @@ struct TP_connection_generic :public TP_connection
|
||||
TP_file_handle fd;
|
||||
bool bound_to_poll_descriptor;
|
||||
int waiting;
|
||||
#ifdef HAVE_IOCP
|
||||
OVERLAPPED overlapped;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
enum_vio_type vio_type;
|
||||
win_aiosocket win_sock{};
|
||||
void init_vio(st_vio *vio) override
|
||||
{ win_sock.init(vio);}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user