Useful to reduce memory use or increase the stack size if Valgrind
segfaults due to stack exhausted.
+* New Option --avg-transtab-entry-size=<number> 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.
" program counters in max <number> frames) [0]\n"
" --num-transtab-sectors=<number> size of translated code cache [%d]\n"
" more sectors may increase performance, but use more memory.\n"
+" --avg-transtab-entry-size=<number> 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=<number> size of valgrind (host) thread's stack\n"
" (in bytes) ["
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) {}
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
"(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. */
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,
/* 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);
#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 );
</term>
<listitem>
<para>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
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 <option>--avg-transtab-entry-size</option>
(about 40 MB per sector for Memcheck). Use the
option <option>--stats=yes</option> to obtain precise
information about the memory used by a sector and the allocation
</listitem>
</varlistentry>
+ <varlistentry id="opt.avg-transtab-entry-size" xreflabel="--avg-transtab-entry-size">
+ <term>
+ <option><![CDATA[--avg-transtab-entry-size=<number> [default: 0,
+ meaning use tool provided default] ]]></option>
+ </term>
+ <listitem>
+ <para>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 <option>--track-origins=yes</option>
+ increases the size of the basic block translations.
+ Use <option>--avg-transtab-entry-size</option> to tune the size of the
+ sectors, either to gain memory or to avoid too many retranslations.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="opt.aspace-minaddr" xreflabel="----aspace-minaddr">
<term>
<option><![CDATA[--aspace-minaddr=<address> [default: depends
program counters in max <number> frames) [0]
--num-transtab-sectors=<number> size of translated code cache [16]
more sectors may increase performance, but use more memory.
+ --avg-transtab-entry-size=<number> avg size in bytes of a translated
+ basic block [0, meaning use tool provided default]
--aspace-minaddr=0xPP avoid mapping memory below 0xPP [guessed]
--valgrind-stacksize=<number> size of valgrind (host) thread's stack
(in bytes) [1048576]
program counters in max <number> frames) [0]
--num-transtab-sectors=<number> size of translated code cache [16]
more sectors may increase performance, but use more memory.
+ --avg-transtab-entry-size=<number> avg size in bytes of a translated
+ basic block [0, meaning use tool provided default]
--aspace-minaddr=0xPP avoid mapping memory below 0xPP [guessed]
--valgrind-stacksize=<number> size of valgrind (host) thread's stack
(in bytes) [1048576]