mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
[MEDIUM] re-implemented the multiple read polling
Multiple read polling was temporarily disabled, which had the side effect of burning huge amounts of CPU on large objects. It has now been re-implemented with a limit of 8 calls per wake-up, which seems to provide best results at least on Linux.
This commit is contained in:
parent
042cc79e59
commit
b8949f1ed0
@ -58,6 +58,12 @@
|
||||
#define MAX_HTTP_HDR ((BUFSIZE+79)/80)
|
||||
#endif
|
||||
|
||||
// max # of loops we can perform around a read() which succeeds.
|
||||
// It's very frequent that the system returns a few TCP segments at a time.
|
||||
#ifndef MAX_READ_POLL_LOOPS
|
||||
#define MAX_READ_POLL_LOOPS 4
|
||||
#endif
|
||||
|
||||
// cookie delimitor in "prefix" mode. This character is inserted between the
|
||||
// persistence cookie and the original value. The '~' is allowed by RFC2965,
|
||||
// and should not be too common in server names.
|
||||
|
@ -40,17 +40,14 @@
|
||||
int stream_sock_read(int fd) {
|
||||
struct buffer *b = fdtab[fd].cb[DIR_RD].b;
|
||||
int ret, max;
|
||||
int read_poll = MAX_READ_POLL_LOOPS;
|
||||
|
||||
#ifdef DEBUG_FULL
|
||||
fprintf(stderr,"stream_sock_read : fd=%d, owner=%p\n", fd, fdtab[fd].owner);
|
||||
#endif
|
||||
|
||||
if (fdtab[fd].state != FD_STERROR) {
|
||||
#ifdef FILL_BUFFERS
|
||||
while (1)
|
||||
#else
|
||||
do
|
||||
#endif
|
||||
while (read_poll-- > 0)
|
||||
{
|
||||
if (b->l == 0) { /* let's realign the buffer to optimize I/O */
|
||||
b->r = b->w = b->lr = b->data;
|
||||
@ -114,9 +111,6 @@ int stream_sock_read(int fd) {
|
||||
break;
|
||||
}
|
||||
} /* while(1) */
|
||||
#ifndef FILL_BUFFERS
|
||||
while (0);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
b->flags |= BF_READ_ERROR;
|
||||
|
Loading…
Reference in New Issue
Block a user