python / python/cpython

Some (mostly) easy ways to reduce the size of JIT generated code

Abierto
#145,742 2 comentarios 1 reacción 1 asignado Ver en GitHub

@corona10 ya está trabajando en esto.

Desde el 24/3/2026.

interpreter-core performance topic-JIT type-feature
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Reducing the size of JIT generated code makes it faster, often super-linearly as there is less code to execute and less code to fill caches.

Looking at the top instructions from old but mostly still valid stats there are a few opportunities to reduce code size:

_SET_IP

Most uses of _SET_IP are setting the ip just in case something wants to inspect it. For these cases, we could store a 16 bit offset instead of the full 64 bit pointer. Code that reads the instruction pointer would need updating, but this should reduce the overhead of _SET_IP by more than half.

_LOAD_CONST_INLINE_BORROW and similar

We can do the tagging when generating the code, instead of while executing. This only saves a single instruction, but it helps.

_LOAD_FAST_BORROW

We already replicate _LOAD_FAST_BORROW, but that still leaves most _LOAD_FAST_BORROW using the slower version, and bloating the stencils.
We could manually generate the code, it is only a couple of instructions, reducing stencil bloat and covering all operands

Linked PRs
  • gh-148081
  • gh-148217
  • gh-148436

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.