python / python/cpython

Improve macOS AArch64 JIT stencils by relaxing GOT loads

Aperta
#157,435 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

interpreter-core OS-mac topic-JIT type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Proposal:

The AArch64 JIT has support for optimising pairs of instructions that load an address through the global offset table (GOT).
On Linux, the JIT optimiser recognises assembly like:

adrp x9, :got:__PyRuntime
ldr  x9, [x9, :got_lo12:__PyRuntime]

https://github.com/python/cpython/blob/0ba7be9a18e8b03af1c046d676f71be9208e06d4/Tools/jit/_optimizers.py#L586-L591

On macOS, Clang uses a different syntax recognised by the Mach-O linker:

adrp x9, __PyRuntime@GOTPAGE
ldr  x9, [x9, __PyRuntime@GOTPAGEOFF]

We can add support for this using the existing patch_aarch64_33rx() function just by adjusting the regex which would enable the same optimisation we already use on Linux:

adrp x9, <__PyRuntime page>
add  x9, x9, <page offset>

This is a natural followup to #157040. I have a small patch ready once jit development is unblocked.

Benchmark:

On my M5 MacBook Pro this shows a 1.16% improvement on the pyperformance suite though results are very noisy. Probably best to re-run with the official benchmarking runners.

Expand for full benchmarking results

Image

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

#148598, #148501, #157040 /cc @diegorusso

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da Tools/jit/_optimizers.py, in patch_aarch64_33rx(), e confronta il pattern esistente di caricamento GOT su Linux con la sintassi macOS di Clang descritta qui. Aggiorna la logica di matching in modo che venga applicata l’ottimizzazione AArch64 esistente, quindi esegui la suite pyperformance o i runner ufficiali di benchmarking per verificare il risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
macos, python
Ambito
compilers, performance
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
72/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.