Skip to content

Commit c49dc3b

Browse files
authored
GH-115802: Optimize JIT stencils for size (GH-136393)
1 parent 798f791 commit c49dc3b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Tools/jit/_targets.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,15 @@ async def _compile(
137137
f"-I{CPYTHON / 'Include' / 'internal' / 'mimalloc'}",
138138
f"-I{CPYTHON / 'Python'}",
139139
f"-I{CPYTHON / 'Tools' / 'jit'}",
140-
"-O3",
140+
# -O2 and -O3 include some optimizations that make sense for
141+
# standalone functions, but not for snippets of code that are going
142+
# to be laid out end-to-end (like ours)... common examples include
143+
# passes like tail-duplication, or aligning jump targets with nops.
144+
# -Os is equivalent to -O2 with many of these problematic passes
145+
# disabled. Based on manual review, for *our* purposes it usually
146+
# generates better code than -O2 (and -O2 usually generates better
147+
# code than -O3). As a nice benefit, it uses less memory too:
148+
"-Os",
141149
"-S",
142150
# Shorten full absolute file paths in the generated code (like the
143151
# __FILE__ macro and assert failure messages) for reproducibility:

0 commit comments

Comments
 (0)