Skip to content

Commit e650bf3

Browse files
allow small loops only
1 parent b149c37 commit e650bf3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/optimizer_analysis.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ optimize_uops(
353353
_Py_uop_abstractcontext_init(ctx);
354354

355355
// Plenty of space and it's a loop, try to peel it.
356-
if (trace[trace_len - 1].opcode == _JUMP_TO_TOP && trace_len < (UOP_MAX_TRACE_LENGTH / 4)) {
356+
// Note: loop peeling only seems to be beneficial at the moment
357+
// for smaller tight loops.
358+
// Bigger loops tend to produce too much jitted code and blow the icache.
359+
if (trace[trace_len - 1].opcode == _JUMP_TO_TOP && trace_len < (UOP_MAX_TRACE_LENGTH / 10)) {
357360
// 1 to skip the _START_EXECUTOR
358361
// + 1 to copy the current instruction too.
359362
for (int x = 1; x < trace_len + 1; x++) {

0 commit comments

Comments
 (0)