summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2014-10-16 21:02:13 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2014-10-16 21:02:13 -0300
commit405b8927fe36df633f70cbed74f1aab1fea0b947 (patch)
tree93085b8c970f6401d88499b454f39ed32f884d37 /shared
parent48e4d181912389c95dd91449dedf5dcb886996a4 (diff)
downloadkmod-405b8927fe36df633f70cbed74f1aab1fea0b947.tar.gz
strbuf: reduce default buffer size
Using 2048 as buffer sizer for strbuf is a bit exaggerated. strbuf is used much more when we are not using mmapped indexes, but it's used for mmapped when for example searching for an alias. A quick and dirty hack to output the size of our strbufs is to print buf->used inside strbuf_str(). Doing this and creating some statistics with: while read xxx alias xxx; do tools/modprobe -R "$alias" > /dev/null; done < /lib/modules/$(uname -r)/modules.alias 2>&1 | \ Rscript -e 'summary (as.numeric (readLines ("stdin")))' Min. 1st Qu. Median Mean 3rd Qu. Max. NA's 1.00 29.00 31.00 31.55 38.00 92.00 26 So, reduce the step to 128, which is still greater than the maximum in these cases. In the worst case this can only create a few calls to realloc(), while keeping the memory footprint low for the common cases.
Diffstat (limited to 'shared')
-rw-r--r--shared/strbuf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/shared/strbuf.c b/shared/strbuf.c
index 374aa00..a11f638 100644
--- a/shared/strbuf.c
+++ b/shared/strbuf.c
@@ -26,7 +26,7 @@
#include "util.h"
#include "strbuf.h"
-#define BUF_STEP (2048)
+#define BUF_STEP 128
static bool buf_grow(struct strbuf *buf, size_t newsize)
{