libdrizzle: performance: in non-blocking mode don't attempt to read after write
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Drizzle |
Fix Released
|
Medium
|
Monty Taylor | ||
7.0 |
Fix Released
|
Medium
|
Monty Taylor |
Bug Description
libdrizzle by default always attempts to read from a connection after it completes a write. This makes sense in blocking mode, but in non-blocking mode it doesn't, since the call to read() frequently returns "EAGAIN." It is more efficient to let epoll/select/
The attached patch is a total hack. It works for me, but I've really only tested non-blocking mode. Not sure if it will break blocking mode clients. Nor am I sure that this is a good way to achieve the desired effect, although it seems to work.
Related branches
- Drizzle Developers: Pending requested
-
Diff: 58 lines (+21/-5)1 file modifiedlibdrizzle/conn.c (+21/-5)
Hi! So - the idea behind this is sound, and I'd be happy to accept a patch doing this conceptually. The main bug in the current patch will manifest on large result sets, where the next state wants to be another write, rather than a read.
A suggestion (thanks eday) would be, you would probably need to keep a flag that this is a partial write, and implement the logic in drizzle_ state_write. Don't touch state.c. Instead of returning ok after a write, if (partial_write), return ok, else set POLLIN and return IO_WAIT. And of course set the partial write flag where needed, which will be a few files.