RustPython / RustPython/Parser
Consider using `Box` on type parameters to reduce statement allocation size
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Rust
- Estrellas
- 117
- Forks
- 38
- Merge medio
- 4 d 7 h
- PR fusionados (30 d)
- 1
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza revisando PR #93 y las definiciones del AST para ClassDef y FunctionDef, centrándote en el campo type_params añadido y en la aserción sobre el tamaño de las sentencias descrita en la discusión. Compara el impacto en las asignaciones del Vec actual con el enfoque propuesto basado en Box, teniendo en cuenta la alternativa tinyvec mencionada; el trabajo estará terminado cuando la representación elegida reduzca el tamaño innecesario de las sentencias sin romper el AST.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- compilers
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100