From 139175f8c48af3ceefb6838dabc0f1222fd150b1 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 3 May 2011 21:14:18 +0200 Subject: [PATCH] Tune loop unrolling heuristics. Increase trace recorder limits. --- doc/running.html | 6 +++--- src/lj_jit.h | 6 +++--- src/lj_record.c | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/running.html b/doc/running.html index cf221a4d..76a393ba 100644 --- a/doc/running.html +++ b/doc/running.html @@ -213,13 +213,13 @@ Here are the parameters and their default settings: maxtrace1000Max. number of traces in the cache -maxrecord2000Max. number of recorded IR instructions +maxrecord4000Max. number of recorded IR instructions maxirconst500Max. number of IR constants of a trace maxside100Max. number of side traces of a root trace -maxsnap100Max. number of snapshots for a trace +maxsnap500Max. number of snapshots for a trace hotloop56Number of iterations to detect a hot loop or hot call @@ -229,7 +229,7 @@ Here are the parameters and their default settings: instunroll4Max. unroll factor for instable loops -loopunroll7Max. unroll factor for loop ops in side traces +loopunroll15Max. unroll factor for loop ops in side traces callunroll3Max. unroll factor for pseudo-recursive calls diff --git a/src/lj_jit.h b/src/lj_jit.h index 92631440..cced4813 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h @@ -67,17 +67,17 @@ /* Optimization parameters and their defaults. Length is a char in octal! */ #define JIT_PARAMDEF(_) \ _(\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. */ \ _(\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, hotexit, 10) /* # of taken exits to start a side trace. */ \ _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ \ _(\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. */ \ _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ \ diff --git a/src/lj_record.c b/src/lj_record.c index 36425086..41b2221a 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -521,7 +521,9 @@ static void rec_loop_interp(jit_State *J, const BCIns *pc, LoopEvent ev) */ if (!innerloopleft(J, pc)) 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. */ J->loopref = J->cur.nins; }