]> granicus.if.org Git - libevent/commitdiff
Increase MIN_BUFFER_SIZE to 512 (1024 on 64-bit)
authorNick Mathewson <nickm@torproject.org>
Fri, 26 Mar 2010 18:30:14 +0000 (14:30 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 26 Mar 2010 18:30:14 +0000 (14:30 -0400)
This constant decides the smallest (and typical) size of each evbuffer
chain.  Since this number includes sizeof(evbuffer_chain) overhead,
the old value (256) was just too low: on 64-bit platforms, it would
spend nearly 20% of the allocations on overhead.  The new values mean
that we'll be spending closer to 5% of evbuffer allocations on overhead.

It would be nice to get this number even lower if we can.

evbuffer-internal.h

index e8555dbd39a4e8d857363c6b5e221a6c4b80f2ee..ce1c347d0bad84891a2f45c426842b67128d5750 100644 (file)
@@ -45,8 +45,15 @@ extern "C" {
 #include <winsock2.h>
 #endif
 #include <sys/queue.h>
-/* minimum allocation for a chain. */
-#define MIN_BUFFER_SIZE        256
+
+/* Minimum allocation for a chain.  We define this so that we're burning no
+ * more than 5% of each allocation on overhead.  It would be nice to lose even
+ * less space, though. */
+#if _EVENT_SIZEOF_VOID_P < 8
+#define MIN_BUFFER_SIZE        512
+#else
+#define MIN_BUFFER_SIZE        1024
+#endif
 
 /** A single evbuffer callback for an evbuffer. This function will be invoked
  * when bytes are added to or removed from the evbuffer. */