Author: adrian.chadd
Date: Wed Feb 4 12:05:09 2009
New Revision: 13799
Modified:
branches/LUSCA_HEAD/src/MemBuf.c
branches/LUSCA_HEAD/src/http.c
Log:
Try to avoid introducing strange performance drops relating
to multiple buffer reallocations.
Document what is going on in the code and the motivations behind
the choices being made.
Modified: branches/LUSCA_HEAD/src/MemBuf.c
==============================================================================
--- branches/LUSCA_HEAD/src/MemBuf.c (original)
+++ branches/LUSCA_HEAD/src/MemBuf.c Wed Feb 4 12:05:09 2009
@@ -1,13 +1,34 @@
#include "squid.h"
+/*
+ * Grow if needed + read into a buffer.
+ * "read_size" is how much to read in in total
+ * and if this isn't available in the buffer, it'll
+ * grow to accomodate it.
+ *
+ * The "grow size" for now is fixed at 8k each time;
+ * that logic needs to change later on to optimise
+ * network throughput.
+ *
+ * This is somewhat hideously bad at the moment but is
+ * being done so the two intended users of this code can
+ * be migrated to use it instead of their own hand
+ * crafted magic. This does mean that -too many reallocations-
+ * will occur!
+ *
+ * The "read_size" is important because src/http.c actually
+ * checks the read size versus read_size to determine whether
+ * the socket buffer was drained or not (at that point in time.)
+ * I don't agree with the logic as its not completely race-proof
+ * _BUT_ I don't want to interfere (much) with it atm.
+ */
int
-buf_read(buf_t *b, int fd, int grow_size)
+buf_read(buf_t *b, int fd, int read_size)
{
int ret;
/* extend buffer to have enough space */
- /* XXX for now, just make it grow 4k bytes at a time */
- buf_grow_to_min_free(b, 4096);
+ buf_grow_to_min_free(b, read_size);
/* read into empty space */
ret = FD_READ_METHOD(fd, buf_buf(b) + buf_len(b), buf_capacity(b) -
buf_len(b));
Modified: branches/LUSCA_HEAD/src/http.c
==============================================================================
--- branches/LUSCA_HEAD/src/http.c (original)
+++ branches/LUSCA_HEAD/src/http.c Wed Feb 4 12:05:09 2009
@@ -1013,12 +1013,19 @@
errno = 0;
CommStats.syscalls.sock.reads++;
+ /*
+ * SQUID_TCP_SO_RCVBUF / 4 here is a ghetto way of trying to avoid
+ * growing the buffer too often. The -eventual- solution will be
+ * to create a second buffer to read the overflow data into;
+ * and growing the buffer only if its part of the reply status +
headers
+ * (as strings atm need to be contiguous) ..
+ */
if (! httpState->read_buf)
- httpState->read_buf = buf_create_size(SQUID_TCP_SO_RCVBUF);
+ httpState->read_buf = buf_create_size(SQUID_TCP_SO_RCVBUF / 4);
/* XXX buffer_filled is all busted right now, unfortunately! */
len = buf_read(httpState->read_buf, fd, read_sz);
- buffer_filled = len == read_sz;
+ buffer_filled = (len == read_sz);
debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, (int) len);
/* Len > 0? Account for data; here's where data would be appended to
the reply buffer */
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---