RustPython / RustPython/Parser
Consider using `Box` on type parameters to reduce statement allocation size
Personne n'a encore pris cette issue.
- Langage dominant
- Rust
- Étoiles
- 117
- Forks
- 38
- Merge moyen
- 4 j 7 h
- PR mergées (30 j)
- 1
Description
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
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner PR #93 et les définitions de l’AST pour ClassDef et FunctionDef, en vous concentrant sur le champ type_params ajouté et sur l’assertion concernant la taille des instructions décrite dans la discussion. Comparez l’impact du Vec actuel sur les allocations avec l’approche proposée basée sur Box, tout en prenant en compte l’alternative tinyvec mentionnée ; le travail est terminé lorsque la représentation choisie réduit la taille inutile des instructions sans casser l’AST.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust
- Domaine
- compilers
- Type d'issue
- Refactorisation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100