diff options
author | Ran Benita <ran234@gmail.com> | 2012-05-30 15:55:21 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2012-06-09 12:34:57 +0300 |
commit | 57f184e21889e7ec72d0eb39dae6972773b706c5 (patch) | |
tree | f2b466b1572f4bc558236560a39c8e7b934851ad /src/darray.h | |
parent | 93ef256063eb4cf6e79275e2113fd388aaf08a51 (diff) | |
download | xorg-lib-libxkbcommon-57f184e21889e7ec72d0eb39dae6972773b706c5.tar.gz |
darray: tweak parameters a bit for better memory usage
Here are some quick numbers from valgrind, running rulescomp only with a
simple, common "us,de" rule set:
before darray: cb047bb
total heap usage: 44,924 allocs, 44,924 frees, 3,162,342 bytes allocated
after darray: c87468e
total heap usage: 52,670 allocs, 52,670 frees, 2,844,517 bytes allocated
tweaking specific inital allocation sizes:
total heap usage: 52,652 allocs, 52,652 frees, 2,841,814 bytes allocated
changing initial alloc = 2 globally
total heap usage: 47,802 allocs, 47,802 frees, 2,833,614 bytes allocated
changing initial alloc = 3 globally
total heap usage: 47,346 allocs, 47,346 frees, 3,307,110 bytes allocated
changing initial alloc = 4 globally
total heap usage: 44,643 allocs, 44,643 frees, 2,853,646 bytes allocated
[ Changing the geometric progression constant from 2 only made things
worse. I tried the golden ratio - not so golden :) ]
The last one is obviously the best, so it was chosen, with the specific
tweaks thrown in as well (these were there before but don't make much
difference). Overall it seems to do better than the previous manual
allocations which is a bit surprising.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/darray.h')
-rw-r--r-- | src/darray.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/darray.h b/src/darray.h index 6c21bbf..2547b47 100644 --- a/src/darray.h +++ b/src/darray.h @@ -280,7 +280,7 @@ typedef darray(unsigned long) darray_ulong; static inline size_t darray_next_alloc(size_t alloc, size_t need) { if (alloc == 0) - alloc = 1; + alloc = 4; while (alloc < need) alloc *= 2; return alloc; |