From: Philippe Waroquiers Date: Sun, 15 Mar 2015 12:24:19 +0000 (+0000) Subject: New Option --avg-transtab-entry-size= can be used to tune X-Git-Tag: svn/VALGRIND_3_11_0~576 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=162d69c37f26f367a1c96186b30979a55c933ab5;p=thirdparty%2Fvalgrind.git New Option --avg-transtab-entry-size= can be used to tune the size of the translation table sectors, either to gain memory or to avoid too many retranslations. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15016 --- diff --git a/NEWS b/NEWS index 4a57638e2a..1e29c4efb6 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,10 @@ Release 3.11.0 is under development, not yet released. Useful to reduce memory use or increase the stack size if Valgrind segfaults due to stack exhausted. +* New Option --avg-transtab-entry-size= can be used to tune + the size of the translation table sectors, either to gain memory + or to avoid too many retranslations. + * Valgrind can be built with Intel's ICC compiler. The required compiler version is 14.0 or later. diff --git a/coregrind/m_main.c b/coregrind/m_main.c index a1de69c7c7..0f902f1335 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -194,6 +194,8 @@ static void usage_NORETURN ( Bool debug_help ) " program counters in max frames) [0]\n" " --num-transtab-sectors= size of translated code cache [%d]\n" " more sectors may increase performance, but use more memory.\n" +" --avg-transtab-entry-size= avg size in bytes of a translated\n" +" basic block [0, meaning use tool provided default]\n" " --aspace-minaddr=0xPP avoid mapping memory below 0xPP [guessed]\n" " --valgrind-stacksize= size of valgrind (host) thread's stack\n" " (in bytes) [" @@ -694,6 +696,9 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd, else if VG_BINT_CLO(arg, "--num-transtab-sectors", VG_(clo_num_transtab_sectors), MIN_N_SECTORS, MAX_N_SECTORS) {} + else if VG_BINT_CLO(arg, "--avg-transtab-entry-size", + VG_(clo_avg_transtab_entry_size), + 50, 5000) {} else if VG_BINT_CLO(arg, "--merge-recursive-frames", VG_(clo_merge_recursive_frames), 0, VG_DEEPEST_BACKTRACE) {} diff --git a/coregrind/m_transtab.c b/coregrind/m_transtab.c index b3d136b14f..f28c3f338b 100644 --- a/coregrind/m_transtab.c +++ b/coregrind/m_transtab.c @@ -59,6 +59,10 @@ UInt VG_(clo_num_transtab_sectors) = N_SECTORS_DEFAULT; Will be set by VG_(init_tt_tc) to VG_(clo_num_transtab_sectors). */ static UInt n_sectors = 0; +/* Average size of a transtab code entry. 0 means to use the tool + provided default. */ +UInt VG_(clo_avg_transtab_entry_size) = 0; + /*------------------ CONSTANTS ------------------*/ /* Number of TC entries in each sector. This needs to be a prime number to work properly, it must be <= 65535 (so that a TT index @@ -2223,7 +2227,10 @@ void VG_(init_tt_tc) ( void ) "(startup of code management)\n"); /* Figure out how big each tc area should be. */ - avg_codeszQ = (VG_(details).avg_translation_sizeB + 7) / 8; + if (VG_(clo_avg_transtab_entry_size) == 0) + avg_codeszQ = (VG_(details).avg_translation_sizeB + 7) / 8; + else + avg_codeszQ = (VG_(clo_avg_transtab_entry_size) + 7) / 8; tc_sector_szQ = N_TTES_PER_SECTOR_USABLE * (1 + avg_codeszQ); /* Ensure the calculated value is not way crazy. */ @@ -2253,6 +2260,13 @@ void VG_(init_tt_tc) ( void ) if (VG_(clo_verbosity) > 2 || VG_(clo_stats) || VG_(debugLog_getLevel) () >= 2) { + VG_(message)(Vg_DebugMsg, + "TT/TC: cache: %s--avg-transtab-entry-size=%d, " + "%stool provided default %d\n", + VG_(clo_avg_transtab_entry_size) == 0 ? "ignoring " : "using ", + VG_(clo_avg_transtab_entry_size), + VG_(clo_avg_transtab_entry_size) == 0 ? "using " : "ignoring ", + VG_(details).avg_translation_sizeB); VG_(message)(Vg_DebugMsg, "TT/TC: cache: %d sectors of %d bytes each = %d total\n", n_sectors, 8 * tc_sector_szQ, diff --git a/coregrind/pub_core_options.h b/coregrind/pub_core_options.h index 60c79e1394..53ccfc0cc9 100644 --- a/coregrind/pub_core_options.h +++ b/coregrind/pub_core_options.h @@ -310,6 +310,10 @@ extern Int VG_(clo_merge_recursive_frames); /* Max number of sectors that will be used by the translation code cache. */ extern UInt VG_(clo_num_transtab_sectors); +/* Average size of a transtab code entry. 0 means to use the tool + provided default. */ +extern UInt VG_(clo_avg_transtab_entry_size); + /* Only client requested fixed mapping can be done below VG_(clo_aspacem_minAddr). */ extern Addr VG_(clo_aspacem_minAddr); diff --git a/coregrind/pub_core_transtab.h b/coregrind/pub_core_transtab.h index 67fd9d82f4..2fd8612f6f 100644 --- a/coregrind/pub_core_transtab.h +++ b/coregrind/pub_core_transtab.h @@ -56,7 +56,8 @@ extern __attribute__((aligned(16))) #define TRANSTAB_BOGUS_GUEST_ADDR ((Addr)1) -/* Initialises the TC, using VG_(clo_num_transtab_sectors). +/* Initialises the TC, using VG_(clo_num_transtab_sectors) + and VG_(clo_avg_transtab_entry_size). VG_(clo_num_transtab_sectors) must be >= MIN_N_SECTORS and <= MAX_N_SECTORS. */ extern void VG_(init_tt_tc) ( void ); diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 21a994ef51..5437bd5368 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -2208,7 +2208,7 @@ need to use them. Valgrind translates and instruments your program's machine - code in small fragments. The translations are stored in a + code in small fragments (basic blocks). The translations are stored in a translation cache that is divided into a number of sections (sectors). If the cache is full, the sector containing the oldest translations is emptied and reused. If these old @@ -2219,6 +2219,7 @@ need to use them. performance by reducing the number of re-translations needed. Sectors are allocated on demand. Once allocated, a sector can never be freed, and occupies considerable space, depending on the tool + and the value of (about 40 MB per sector for Memcheck). Use the option to obtain precise information about the memory used by a sector and the allocation @@ -2226,6 +2227,28 @@ need to use them. + + + + + + Average size of translated basic block. This average size + is used to dimension the size of a sector. + Each tool provides a default value to be used. + If this default value is too small, the translation sectors + will become full too quickly. If this default value is too big, + a significant part of the translation sector memory will be unused. + Note that the average size of a basic block translation depends + on the tool, and might depend on tool options. For example, + the memcheck option + increases the size of the basic block translations. + Use to tune the size of the + sectors, either to gain memory or to avoid too many retranslations. + + + +