Consider using `Box` on type parameters to reduce statement allocation size
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne mit der Überprüfung von PR #93 und den AST-Definitionen für ClassDef und FunctionDef, wobei du dich auf das hinzugefügte Feld type_params und die in der Diskussion beschriebene Assertion zur Statement-Größe konzentrierst. Vergleiche die Auswirkungen der aktuellen Vec-Implementierung auf die Allokation mit dem vorgeschlagenen Box-Ansatz und berücksichtige dabei die erwähnte tinyvec-Alternative; die Arbeit ist abgeschlossen, wenn die gewählte Repräsentation die unnötige Statement-Größe reduziert, ohne den AST zu beschädigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Rust
- Sterne
- 117
- Forks
- 38
- Ø Merge
- 4 T. 7 Std.
- Gemergte PRs (30 T.)
- 1
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RustPython/Parser
-
Maintenance status Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 25/100
RustPython/Parser#140 · 3 Kommentare ·
-
`unic` is unmaintained Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
RustPython/Parser#139 · 3 Kommentare ·
-
cargo audit paste Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
RustPython/Parser#137 · 1 Kommentar ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 50/100
RustPython/Parser#133 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
RustPython/Parser#130 ·