RustPython / RustPython/Parser
Consider using `Box` on type parameters to reduce statement allocation size
Nessuno ha ancora preso questa issue.
- Lingua principale
- Rust
- Stelle
- 117
- Fork
- 38
- Merge medio
- 4g 7h
- PR unite (30g)
- 1
Descrizione
In https://github.com/RustPython/Parser/pull/93, we add type_params: Vec to ClassDef and FunctionDef which increases the size of a statement. We may want to optimize this field to reduce the size of the statement struct.
The main reason for the assertion is to be aware of how changing the AST changes its size. This is important because ruff and RustPython hold many instances of these types and increasing their size mean:
- Each element in a
Vecnow requires more storage -> Overall increased memory consumption- Reading or writing an element becomes slower because your computer must read or write more bytes. This is especially relevant for reading where the L1 cache short circuits reads by caching about 64 bytes of neighboring memory to avoid subsequent reads from (the very slow) memory.
There's not much we can do about this here. This could be a place where using
tinyvecover a regularVecwould be beneficial, considering that the vec will be empty for almost all instances. But I think this is fine for now.
Originally posted by @MichaReiser in https://github.com/RustPython/Parser/pull/93#discussion_r1259220991
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando PR #93 e le definizioni dell’AST per ClassDef e FunctionDef, concentrandoti sul campo type_params aggiunto e sull’asserzione relativa alle dimensioni delle istruzioni descritta nella discussione. Confronta l’impatto sulle allocazioni dell’attuale Vec con l’approccio proposto basato su Box, considerando anche l’alternativa tinyvec menzionata; il lavoro è completato quando la rappresentazione scelta riduce le dimensioni non necessarie delle istruzioni senza compromettere l’AST.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- compilers
- Tipo di issue
- Refactoring
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100