RustPython / RustPython/Parser
Consider using `Box` on type parameters to reduce statement allocation size
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 117
- フォーク
- 38
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 1
説明
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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず PR #93 と ClassDef および FunctionDef の AST 定義を確認し、追加された type_params フィールドと、議論で説明されている文のサイズに関するアサーションに注目してください。現在の Vec によるアロケーションへの影響と、提案されている Box アプローチを比較し、言及されている tinyvec の代替案も考慮してください。選択した表現によって不要な文のサイズが削減され、AST を壊さなければ作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100