RustPython / RustPython/Parser
Consider using `Box` on type parameters to reduce statement allocation size
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Rust
- Sterne
- 117
- Forks
- 38
- Ø Merge
- 4 T. 7 Std.
- Gemergte PRs (30 T.)
- 1
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
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.
Bewertung
- Tech-Stack
- rust
- Bereich
- compilers
- Issue-Typ
- Refactoring
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100