mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-08 21:09:49 +00:00
This patch adds a function that allows to directly properly size an xarray
when the size is known in advance. 3 places identified where this function can be used trivially. The result is a reduction of 'realloc' operations in core arena, and a small reduction in ttaux arena (it is the nr of operations that decreases, the memory usage itself stays the same (ignoring some 'rounding' effects). E.g. for perf/bigcode 0, we change from core 1085742/ 216745904 totalloc-blocks/bytes, 1085733 searches ttaux 5348/ 6732560 totalloc-blocks/bytes, 5326 searches to core 712666/ 190998592 totalloc-blocks/bytes, 712657 searches ttaux 5319/ 6731808 totalloc-blocks/bytes, 5296 searches For bz2, we switch from core 50285/ 32383664 totalloc-blocks/bytes, 50256 searches ttaux 670/ 245160 totalloc-blocks/bytes, 669 searches to core 32564/ 29971984 totalloc-blocks/bytes, 32535 searches ttaux 605/ 243280 totalloc-blocks/bytes, 604 searches Performance wise, on amd64, this improves memcheck performance on perf tests by 0.0, 0.1 or 0.2 seconds depending on the test. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15173
This commit is contained in:
@@ -104,6 +104,13 @@ extern Bool VG_(lookupXA_UNSAFE) ( const XArray* xao, const void* key,
|
||||
/* How elements are there in this XArray now? */
|
||||
extern Word VG_(sizeXA) ( const XArray* );
|
||||
|
||||
/* If you know how many elements an XArray will have, you can
|
||||
optimise memory usage and number of reallocation needed
|
||||
to insert these elements. The call to VG_(hintSizeXA) must be
|
||||
done just after the call to VG_(newXA), before any element
|
||||
has been inserted. */
|
||||
extern void VG_(hintSizeXA) ( XArray*, Word);
|
||||
|
||||
/* Index into the XArray. Checks bounds and bombs if the index is
|
||||
invalid. What this returns is the address of the specified element
|
||||
in the array, not (of course) the element itself. Note that the
|
||||
|
||||
Reference in New Issue
Block a user