python / python/cpython

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

Aberta
#145,742 2 comentários 1 reação 1 responsável Ver no GitHub

@corona10 já está trabalhando nisso.

Desde 24/3/2026.

interpreter-core performance topic-JIT type-feature
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.