Consider using `Box` on type parameters to reduce statement allocation size

Abierto
#94 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Refactorización
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
rust
Área
compilers

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.

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 Vec now 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 tinyvec over a regular Vec would 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

Lenguaje dominante
Rust
Estrellas
117
Forks
38
Merge medio
4 d 7 h
PR fusionados (30 d)
1

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de RustPython/Parser

Todos los issues de RustPython/Parser

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.