Tune loop unrolling heuristics. Increase trace recorder limits.

This commit is contained in:
Mike Pall 2011-05-03 21:14:18 +02:00
parent c77ca54564
commit 139175f8c4
3 changed files with 9 additions and 7 deletions

View File

@ -213,13 +213,13 @@ Here are the parameters and their default settings:
<tr class="odd separate"> <tr class="odd separate">
<td class="param_name">maxtrace</td><td class="param_default">1000</td><td class="param_desc">Max. number of traces in the cache</td></tr> <td class="param_name">maxtrace</td><td class="param_default">1000</td><td class="param_desc">Max. number of traces in the cache</td></tr>
<tr class="even"> <tr class="even">
<td class="param_name">maxrecord</td><td class="param_default">2000</td><td class="param_desc">Max. number of recorded IR instructions</td></tr> <td class="param_name">maxrecord</td><td class="param_default">4000</td><td class="param_desc">Max. number of recorded IR instructions</td></tr>
<tr class="odd"> <tr class="odd">
<td class="param_name">maxirconst</td><td class="param_default">500</td><td class="param_desc">Max. number of IR constants of a trace</td></tr> <td class="param_name">maxirconst</td><td class="param_default">500</td><td class="param_desc">Max. number of IR constants of a trace</td></tr>
<tr class="even"> <tr class="even">
<td class="param_name">maxside</td><td class="param_default">100</td><td class="param_desc">Max. number of side traces of a root trace</td></tr> <td class="param_name">maxside</td><td class="param_default">100</td><td class="param_desc">Max. number of side traces of a root trace</td></tr>
<tr class="odd"> <tr class="odd">
<td class="param_name">maxsnap</td><td class="param_default">100</td><td class="param_desc">Max. number of snapshots for a trace</td></tr> <td class="param_name">maxsnap</td><td class="param_default">500</td><td class="param_desc">Max. number of snapshots for a trace</td></tr>
<tr class="even separate"> <tr class="even separate">
<td class="param_name">hotloop</td><td class="param_default">56</td><td class="param_desc">Number of iterations to detect a hot loop or hot call</td></tr> <td class="param_name">hotloop</td><td class="param_default">56</td><td class="param_desc">Number of iterations to detect a hot loop or hot call</td></tr>
<tr class="odd"> <tr class="odd">
@ -229,7 +229,7 @@ Here are the parameters and their default settings:
<tr class="odd separate"> <tr class="odd separate">
<td class="param_name">instunroll</td><td class="param_default">4</td><td class="param_desc">Max. unroll factor for instable loops</td></tr> <td class="param_name">instunroll</td><td class="param_default">4</td><td class="param_desc">Max. unroll factor for instable loops</td></tr>
<tr class="even"> <tr class="even">
<td class="param_name">loopunroll</td><td class="param_default">7</td><td class="param_desc">Max. unroll factor for loop ops in side traces</td></tr> <td class="param_name">loopunroll</td><td class="param_default">15</td><td class="param_desc">Max. unroll factor for loop ops in side traces</td></tr>
<tr class="odd"> <tr class="odd">
<td class="param_name">callunroll</td><td class="param_default">3</td><td class="param_desc">Max. unroll factor for pseudo-recursive calls</td></tr> <td class="param_name">callunroll</td><td class="param_default">3</td><td class="param_desc">Max. unroll factor for pseudo-recursive calls</td></tr>
<tr class="even"> <tr class="even">

View File

@ -67,17 +67,17 @@
/* Optimization parameters and their defaults. Length is a char in octal! */ /* Optimization parameters and their defaults. Length is a char in octal! */
#define JIT_PARAMDEF(_) \ #define JIT_PARAMDEF(_) \
_(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \ _(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \
_(\011, maxrecord, 2000) /* Max. # of recorded IR instructions. */ \ _(\011, maxrecord, 4000) /* Max. # of recorded IR instructions. */ \
_(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \
_(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \
_(\007, maxsnap, 100) /* Max. # of snapshots for a trace. */ \ _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \
\ \
_(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \
_(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \
_(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \
\ \
_(\012, instunroll, 4) /* Max. unroll for instable loops. */ \ _(\012, instunroll, 4) /* Max. unroll for instable loops. */ \
_(\012, loopunroll, 7) /* Max. unroll for loop ops in side traces. */ \ _(\012, loopunroll, 15) /* Max. unroll for loop ops in side traces. */ \
_(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \ _(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \
_(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \
\ \

View File

@ -521,7 +521,9 @@ static void rec_loop_interp(jit_State *J, const BCIns *pc, LoopEvent ev)
*/ */
if (!innerloopleft(J, pc)) if (!innerloopleft(J, pc))
lj_trace_err(J, LJ_TRERR_LINNER); /* Root trace hit an inner loop. */ lj_trace_err(J, LJ_TRERR_LINNER); /* Root trace hit an inner loop. */
if ((J->loopref && J->cur.nins - J->loopref > 8) || --J->loopunroll < 0) if ((J->loopref && J->cur.nins - J->loopref >
((IRRef)J->param[JIT_P_maxrecord] >> 5)) ||
--J->loopunroll < 0)
lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */
J->loopref = J->cur.nins; J->loopref = J->cur.nins;
} }