RustPython / RustPython/Parser

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

Aberta
#94 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
Rust
Estrelas
117
Forks
38
Merge médio
4d 7h
PRs com merge (30d)
1

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece revisando o PR #93 e as definições da AST para ClassDef e FunctionDef, concentrando-se no campo type_params adicionado e na asserção sobre o tamanho das instruções descrita na discussão. Compare o impacto de alocação do Vec atual com a abordagem proposta usando Box, considerando também a alternativa tinyvec mencionada; o trabalho estará concluído quando a representação escolhida reduzir o tamanho desnecessário das instruções sem quebrar a AST.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
rust
Domínio
compilers
Tipo de issue
Refatoração
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.