Consider using `Box` on type parameters to reduce statement allocation size
まだ誰も着手していません。
評価
調査の方向性
まず PR #93 と ClassDef および FunctionDef の AST 定義を確認し、追加された type_params フィールドと、議論で説明されている文のサイズに関するアサーションに注目してください。現在の Vec によるアロケーションへの影響と、提案されている Box アプローチを比較し、言及されている tinyvec の代替案も考慮してください。選択した表現によって不要な文のサイズが削減され、AST を壊さなければ作業は完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Rust
- スター
- 117
- フォーク
- 38
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustPython/Parser のほかの issue
-
Maintenance status オープン
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
RustPython/Parser#140 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
RustPython/Parser#139 · コメント 3 件 ·
-
cargo audit paste オープン
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
RustPython/Parser#137 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
RustPython/Parser#133 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
RustPython/Parser#130 ·
RustPython/Parser の issue をすべて見る
似ている issue
-
risk:low runtime status:in-progress type:test
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
EricSpencer00/Resilient#4835 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
bisq-network/bisq-musig#204 ·
-
agent:ready documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
cesarferreira/stax#890 ·