aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wmem/wmem_test.c
AgeCommit message (Collapse)AuthorFilesLines
2017-03-04Add wmem_tree_count.Michael Mann1-0/+4
There are cases where wmem_tree needs to know its number of nodes. Change-Id: I6411cf4275fd4d85a1d76382e1922d236be3b176 Reviewed-on: https://code.wireshark.org/review/20005 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-08wmem_list: add wmem_list_insert_sorted.Dario Lombardo1-0/+63
This mimics the function g_list_insert_sorted. Change-Id: I6f7ac01155588006662c8c0c138d88cea753868c Reviewed-on: https://code.wireshark.org/review/19978 Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-01-28Add wmem_map_new_autoresetMichael Mann1-1/+20
This can be used similarly to wmem_tree_new_autoreset for hash tables that need reset after capture file change. Change-Id: I3a2f0b0a0cad3eca46266523c594d3d7aac17489 Reviewed-on: https://code.wireshark.org/review/19794 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com>
2016-07-30ifdef out a variable used only on Windows.Guy Harris1-1/+3
Also, fix identation - tab stops are set every 8 spaces, not every 4 spaces, in UN*X, which is why the mode lines specify that. Change-Id: If7cfc2cdae26feb2d5c13e31a32ed950354fb15b Reviewed-on: https://code.wireshark.org/review/16789 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-30Add string function times to wmem_test.Gerald Combs1-0/+159
The system, GLib, and wmem string functions can perform differently, particularly on Windows. Start adding performance tests to wmem_test so that we can see the differences. With this change applied "wmem_test --verbose" prints out the following on a Windows 7 x64 VM here. wmem_test is linked against GLib 2.4.20. (MINPERF:g_printf_string_upper_bound (via g_snprintf) 1 string: u 327.602 ms s 0 .000 ms) (MINPERF:g_printf_string_upper_bound (via g_snprintf) 5 strings: u 1419.609 ms s 0.000 ms) (MINPERF:g_printf_string_upper_bound (via g_snprintf) mixed args: u 1606.810 ms s 0.000 ms) (MINPERF:_snprintf_s upper bound 1 string: u 124.801 ms s 0.000 ms) (MINPERF:_snprintf_s upper bound 5 strings: u 140.401 ms s 0.000 ms) (MINPERF:_snprintf_s upper bound mixed args: u 124.801 ms s 0.000 ms) (MINPERF:g_strdup_printf 2 strings: u 702.005 ms s 0.156 ms) (MINPERF:g_strconcat 2 strings: u 78.000 ms s 0.000 ms) (MINPERF:g_strdup_printf 5 strings: u 1419.609 ms s 0.156 ms) (MINPERF:g_strconcat 5 strings: u 93.601 ms s 0.156 ms) (MINPERF:wmem_strdup_printf 2 strings: u 343.202 ms s 0.312 ms) (MINPERF:wmem_strconcat 2 strings: u 93.601 ms s 0.468 ms) (MINPERF:wmem_strdup_printf 5 strings: u 327.602 ms s 8.268 ms) (MINPERF:wmem_strconcat 5 strings: u 62.400 ms s 3.432 ms) Change-Id: Id9b23918829db1719d141e7f830b9eba6245a25b Reviewed-on: https://code.wireshark.org/review/14857 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-22wmem: add wmem_map_size().Dario Lombardo1-0/+8
Change-Id: I3acca7939466a4436e23bcf828ef94f927ce8b76 Reviewed-on: https://code.wireshark.org/review/15042 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-22wmem: add foreach function to wmem_map.Dario Lombardo1-2/+17
Makes wmem_map more similar to g_hash. Change-Id: Ia17a19ab0be8e07fbb64801d54db2ba8217a7fea Reviewed-on: https://code.wireshark.org/review/15020 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-20wmem: add foreach function to wmem_list.Dario Lombardo1-0/+13
Makes wmem_list more similar to glib lists. Change-Id: Ifadf0627791a72c4118a14f205aa1a7189894d27 Reviewed-on: https://code.wireshark.org/review/15019 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-03-26Improves MPTCP analysisMatthieu Coudron1-0/+1
Adds options that control depth of MPTCP analysis, notably: - if mptcp_relative_seq is enabled, can display relative MPTCP sequence numbers - if mapping analysis is allowed, can tell in which packets the DSS mappings covering this data was sent - if intersubflow checks are enabled, it can check for retransmissions over other subflows Change-Id: I82b934513c9f16affb60c066a1fbcca234ffc999 Reviewed-on: https://code.wireshark.org/review/12316 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-02-22wmem: add null-terminator support.Dario Lombardo1-0/+10
This change makes wmem_array more similar to GArray by adding two functions that mimic the first two params of g_array_new(). Change-Id: Iaec999cd2e44f79f44d766be5d39741b73602e5a Reviewed-on: https://code.wireshark.org/review/13989 Petri-Dish: Evan Huus <eapache@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com>
2015-11-25No declarations in the middle of code.Guy Harris1-1/+1
We crank up pedantic warnings enough that this provokes "warning: ISO C90 forbids mixed declarations and code" on the OS X 10.5 buildbot. Change-Id: Ic3962f20d85e3ed003b84b298f83d12c3ae25ea1 Reviewed-on: https://code.wireshark.org/review/12120 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-24Introduces augmented interval treesMatthieu Coudron1-0/+105
Interval trees (wmem_itree_t) are implemented as an extension of wmem_tree with a guint64-based range as the key. This is useful for instance in MPTCP analysis, to look for packets matching a range defined by a mapping across TCP subflows. Change-Id: Iea706d44fe975e390a4191ad0257ef37d5c71525 Reviewed-on: https://code.wireshark.org/review/11714 Reviewed-by: Evan Huus <eapache@gmail.com> Petri-Dish: Evan Huus <eapache@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-11Change prototype of callbacks passed to wmem_tree_foreach so that theyMatthieu Coudron1-1/+1
accept the node key as a first parameter. wmem_tree accepts all sort of keys (strings, integers, soon ranges), thus it is of interest for various purposes (testing, greedy search) to know the key of the node. Change-Id: Ie748b917bef91f0b1ba8cce15bd1b471922641dc Reviewed-on: https://code.wireshark.org/review/11683 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-08-03wmem: get rid of the allocator timing testEvan Huus1-59/+0
Some of the allocators are close enough that a little bit of system load at the time of the test was enough to throw them off, and it was causing unnecessary buildbot failures. Benchmarking on real-world cases at the time of implementation (as well as reliable "average" results on the buildbots) has left me confident that block_fast is, in fact, faster than block, which is faster than simple/strict. Additionally, the allocators are effectively "done" and unlikely to change, so the possibility of uncaught performance regressions is low. Change-Id: I144ea4cd9d6000edc4075ed682ce6a4aeaf5e28a Reviewed-on: https://code.wireshark.org/review/3356 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-01Bump (again) the amount of work we do for wmem's timing testEvan Huus1-1/+1
Apparently the new win8 vm has a *very* low-resolution timer, and the allocators are indistinguishable at the previous amount of work. Change-Id: If4e5bb8f85b1f0d39658f54001c88f42ffddfc47 Reviewed-on: https://code.wireshark.org/review/2768 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-23Add jumbo-allocation support to wmem fast blockEvan Huus1-0/+1
As it turns out, we do occasionally need it. Bug:10115 Change-Id: Ifec79e4d2470bbc09f15674534d01418a6571a0d Reviewed-on: https://code.wireshark.org/review/1688 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-17Fix newly optimized strdup_vprintf.Evan Huus1-0/+3
As Jakub pointed out, our +1/-1 logic for null terminators wasn't quite right. Also be sure to re-copy the va_list parameter if we need to re-use it, as otherwise things break oddly. Change-Id: Ibeaa95af602f565791e9378a6cfce434f13025eb Reviewed-on: https://code.wireshark.org/review/1670 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-06Increase the work used to time wmem allocatorsEvan Huus1-1/+7
It appears that on some platforms the timer underlying g_test_timer() is relatively low-precision, so the small amount of work that we were previously doing was not enough for the timer to provide a useful value. Bumping the amount of work should provide more meaningful values, and the whole timing step still takes only a few seconds. Change-Id: Idce1386eaa33add845d9a2758b0beb72bbf370d6 Reviewed-on: https://code.wireshark.org/review/1523 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-05Fix dead assignment found by clang in test codeEvan Huus1-1/+1
Change-Id: Ie78769bfd8034f6c2ee7d9e26a209d650cedb98d Reviewed-on: https://code.wireshark.org/review/1507 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-05-05Reduce wmem fast-block fuzz rounds even furtherEvan Huus1-1/+1
Follow-up to g19e650f43adf23b0aa92821bff0cc389643944f6 since the fuzz-bot is still failing. Change-Id: I2d05a861b0edf50ce734b682e6e3e33729bf6771 Reviewed-on: https://code.wireshark.org/review/1503 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-04Fuzz fewer iterations of the fast block allocatorEvan Huus1-6/+11
I believe the XP buildbot failures are simply running out of memory, so hopefully reducing the number of iterations should be enough to let it finish reliably. Change-Id: I40af789d528c2623e95f153529205b5e617c6e02 Reviewed-on: https://code.wireshark.org/review/1496 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-02wmem: add new simple block allocator, use it in packet-scope.Jakub Zawadzki1-30/+61
For packet-scope allocation, there's no need to support realloc(), free() cause memory will be garbage collected after packet dissection. (and this allocator is much faster than full block allocator). Change-Id: I73fdf708c3077f48f55bdcc71f4fa859e4ac2335 Reviewed-on: https://code.wireshark.org/review/1428 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-02Reintroduce wmem_allocator_force_newEvan Huus1-4/+36
We now have to call wmem_init in order to randomly seed the values for wmem_map. This means we can no longer rely on the lack of override, so we have to force the right allocator type when testing/timing the allocators themselves. Change-Id: I005034465b0a98f19876899b96ef65b3e4b1d759 Reviewed-on: https://code.wireshark.org/review/1468 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-23Hash map implementation for wmem.Evan Huus1-2/+59
This has two expected uses: - Many current users of wmem_tree don't actually need the predecessor lookup it provides (the lookup_le function family). A hash map provides straight insertion and lookup much more efficiently than a wmem_tree when predecessor lookup isn't needed. - Many current users of glib's hash table and hash functions use untrusted data for keys, making them vulnerable to algorithmic complexity attacks. Care has been taken to make this implementation secure against such attacks, so it should be used whenever data is untrusted. In my benchmarks it is measurably slower than GHashTable, but not excessively so. Given the additional security it provides this seems like a reasonable trade-off (and it is still faster than a wmem_tree). Change-Id: I2d67a0d06029f14c153eaa42d5cfc774aefd9918 Reviewed-on: https://code.wireshark.org/review/1272 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-12Fix non-standard format specifiersEvan Huus1-1/+1
C90 permits plain %f for doubles. Thanks to Alexis for pointing this out. Change-Id: I3f927b0a50e5764c2297c7f9d680c6363ba9fd0e Reviewed-on: https://code.wireshark.org/review/1073 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-02Scrap wmem splay trees for now.Evan Huus1-186/+0
There is confusion about API usage, and problems on my part concerning whether keys should be compared signed or unsigned, and how to do that efficiently. Unsigned keys in particular were behaving oddly. Change-Id: I075693bbd04c15f79f24f9a24006003a914cc572 Reviewed-on: https://code.wireshark.org/review/924 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-29Splay tree implementation for wmemEvan Huus1-1/+189
This is a tree implementation intended to replace the current red-black tree in wmem_tree (which was inherited from emem), assuming there are no regressions. Splay trees bubble recently accessed keys to the top, and as such have a number of very nice properties: https://en.wikipedia.org/wiki/Splay_tree This implementation is a variant known as "independent semi-splaying", which has better practical performance. It should do about as well as the red-black tree for random insertions and accesses, but somewhat better for patterned accesses (such as accessing each key in order, or accessing certain keys very frequently). There are a few other changes relative to the red-black tree implementation that are worth mentioning: - Instead of requiring complex keys to be split into guint32 chunks and doing this weird trick with sub-trees, I let the keys be arbitrary pointers and allowed the user to specify an arbitrary comparison function. If the function is NULL then the pointers are compared directly for the simple integer-key case. - Splay trees do not need to store a red-black colour flag for each node. It is also much easier to do without the parent pointer in each node. And due to the simpler system for complex keys, I was able to remove the "is_subtree" boolean. As such, splay nodes are 12 bytes smaller on 32-bit platforms, and 16 bytes smaller on a 64-bit platform. All done in about half the lines of code. Change-Id: I89fb57e07d2bb7e3197190c7c2597b0c5adcc03b Reviewed-on: https://code.wireshark.org/review/758 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-29Implement finalize() method for wmem strbuf.Evan Huus1-0/+5
Change-Id: Ib7a2b0d348b3624f41253e2d0995a4a38a9fe45d Reviewed-on: https://code.wireshark.org/review/859 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-25Introduce wmem_ascii_strdown()AndersBroman1-0/+5
Change-Id: Icdc5a0d5033f3ab709fbf19a33ab26f609d4b1f0 Reviewed-on: https://code.wireshark.org/review/824 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-01-05From Jim Young via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9613Evan Huus1-3/+3
Don't use "rand" as a variable name, it shadows a global in recent MacOSX stdlib.h svn path=/trunk/; revision=54598
2013-12-24Add wmem_destroy_list, wmem_destroy_queue, wmem_destroy_stack so that thoseEvan Huus1-0/+11
data-structures can be used with manually managed memory. svn path=/trunk/; revision=54432
2013-12-20Fix [-Wmissing-prototypes]Anders Broman1-1/+1
svn path=/trunk/; revision=54280
2013-12-15Fix some const/ not const warnings.Jakub Zawadzki1-2/+2
svn path=/trunk/; revision=54114
2013-10-15As suggested separately by both Jakub and Anders: only read theEvan Huus1-36/+4
WIRESHARK_DEBUG_WMEM_OVERRIDE environment variable once in wmem_init, not every time wmem_allocator_new is called. We currently create a new pinfo pool for every packet we dissect, so this is a small performance win, especially when getenv is slow (which may happen if a large number of environment variables are set, such as when fuzz-testing). svn path=/trunk/; revision=52634
2013-09-01Send all alloc and free calls within wmem through wmem_alloc and wmem_free withEvan Huus1-1/+1
a NULL allocator. This gives us a single, central place to handle out-of-memory errors (by, for example, throwing an exception) for basically all of epan. The only remaining glib memory that is directly allocated is for the hash tables used by the simple and strict allocators. svn path=/trunk/; revision=51627
2013-08-14Include config.h first; it defines _FILE_OFFSET_BITS, and if some systemGuy Harris1-1/+3
header later causes it to be redefined - as happens on my Solaris 11 virtual machine - we get a redefinition warning, which gets treated as an error. svn path=/trunk/; revision=51344
2013-08-11Add support for allocating more than will fit in a single block, through the useEvan Huus1-1/+16
of a jumbo flag in the chunk header. svn path=/trunk/; revision=51299
2013-07-31Add wmem_tree_is_empty(). Also permit lookups on a NULL tree for compatibilityEvan Huus1-0/+2
with emem. svn path=/trunk/; revision=51045
2013-07-28Don't force the allocator choice in the data-structure tests, we want to be ableEvan Huus1-10/+10
to override that to simple for valgrinding (we still force the allocator in the allocator and timing tests, of course). svn path=/trunk/; revision=50971
2013-07-28Fix a bug in the gc routine discovered while formally working out parts of theEvan Huus1-0/+10
algorithm. Also add a test case to excercise it for future. svn path=/trunk/; revision=50970
2013-07-27Use a #define, tweak a comment.Evan Huus1-2/+2
svn path=/trunk/; revision=50954
2013-07-21Add wmem queue 'implementation' by wrapping wmem_list and wmem_stack.Evan Huus1-0/+32
Also a bit of misc. refactoring of the stack while I was there, and doc tweaks. svn path=/trunk/; revision=50769
2013-07-20Replace wmem slist (singly-linked) with wmem list (doubly-linked).Evan Huus1-28/+45
The overhead is not large, and it makes append much faster (O(1) vs O(n)). It also will make a queue easy to add, which I need for a dissector I'm writing... svn path=/trunk/; revision=50744
2013-07-06Add wmem_array_sort() which just hands off to the standard library's qsort().Evan Huus1-1/+31
svn path=/trunk/; revision=50411
2013-07-06Simple growable array implementation for wmem.Evan Huus1-0/+53
svn path=/trunk/; revision=50400
2013-06-27*sigh*Evan Huus1-3/+5
From the comment above wmem_tree_insert32_array(): * If you use ...32_array() calls you MUST make sure that every single node * you add to a specific tree always has a key of exactly the same number of * keylen words or things will most likely crash. Or at least that every single * item that sits behind the same top level node always have exactly the same * number of words. So clearly generating thousands of keys with random lengths while testing is going to cause problems. Generate a set of random lengths, then use those lengths consistently (but still generating random keys of those lengths). Should hopefully fix the intermittent build-bot failures. (unfortunately this does not manifest nicely, and I cannot see an easy way to assert it so that we catch other people trying to use different-length key subtrees) svn path=/trunk/; revision=50184
2013-06-27Remove debugging lines from wmem_test, I think I've figured out the problem.Evan Huus1-26/+0
svn path=/trunk/; revision=50181
2013-06-25Arrays seems to be where the failure is, so remove excess verbiage around otherEvan Huus1-47/+19
tests, and add more details to that section. Now we wait for the buildbots to fail again... svn path=/trunk/; revision=50156
2013-06-24So it comes to this...Evan Huus1-0/+54
Put in a whole bunch of stderr output in the wmem tree tests in the hopes that the next time one of the buildbots randomly (and irreproducibly) fails on this step we'll have at least a bit of a hint as to where it happened. svn path=/trunk/; revision=50131