[PATCH] Freeing large buffers...

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 10/15/97


        Here's a patch on the list of TODO things...it imposes the least
overhead possible.  If you don't have a problem with many large buffers
(type: show stats) then you won't need this patch.  If you do have many
buffers hanging around, then this patch will eliminate a buffer 25% of the
time after it is used so the average buffer lifespan is 4 uses.  This does
have the drawback that it doesn't check for idle times, usage, number of
buffers, etc, but there are better ways (EBAS) of doing that and this will,
at least, help a little.

diff -upPr -x *.o ../stk/comm.c ./comm.c
--- ../stk/comm.c       Sun Apr 14 14:28:46 1996
+++ ./comm.c    Wed Oct 15 15:39:45 1997
@@ -1092,11 +1092,16 @@ int process_output(struct descriptor_dat
   }
   /*
    * if we were using a large buffer, put the large buffer on the buffer pool
-   * and switch back to the small one
+   * and switch back to the small one, or 25% of the time just free it.
    */
   if (t->large_outbuf) {
-    t->large_outbuf->next = bufpool;
-    bufpool = t->large_outbuf;
+    if (number(0, 3)) {                /* Keep it. */
+      t->large_outbuf->next = bufpool;
+      bufpool = t->large_outbuf;
+    } else {                   /* Free it. */
+      free(t->large_outbuf);
+      buf_largecount--;
+    }
     t->large_outbuf = NULL;
     t->output = t->small_outbuf;
   }

Tested by loading 200 Puff's in a room and alternating 'look' and 'show
stats'.

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST