JIT: Interprocedural analysis for out parameters
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
This is open-ended JIT design work: the body asks whether to compile specialized versions of methods with out parameters or to strengthen the inliner, and names no file. Start by reading the linked PR 138016 to see the local-variable rewrite it used, and the JIT inliner sources under src/coreclr/jit. Done means a design agreed with the JIT maintainers (@jkotas, @dotnet/jit-contrib), not a patch.
索引モデルが issue の本文から書いたものです。
説明
It seems that in the vast majority of calls with out parameters, callers declare the corresponding arguments inline:
void Foo(..., out int written)
{
...
written++;
...
written++;
}
// typical usage
Foo(..., out int written);
Knowing that an out argument is on the stack and is not aliased can help the JIT generate better code. For example, https://github.com/dotnet/runtime/pull/138016 made one benchmark nearly 2.5x faster by updating a local variable instead of modifying the out argument directly.
Suggestion
Could we compile two versions of each method with out parameters: a default version and a specialized version that uses this hint? The JIT could then choose the appropriate version at each call site. The ReJIT concern still applies, but is there anything else I'm missing?
Alternatively, we can boost the inliner additionally.
cc @jkotas @dotnet/jit-contrib
Data
Roslyn syntax scan over the product code in src/libraries and src/coreclr/System.Private.CoreLib, excluding tests and ref folders (12,463 files, 15,780 out arguments at call sites):
out argument kind |
Share |
|---|---|
inline decl (out var x / out T x) |
37.4% |
| pre-declared local | 26.6% |
forwarded out param (TryX -> TryXCore) |
23.4% |
discard (out _ / out var _) |
7.2% |
field / this.x / arr[i] / *p / ref param / other |
5.4% |
Inline declarations are about 37%. All non-aliased stack locals (inline + pre-declared + discard) add up to about 71%.
- 主要言語
- C#
- スター
- 18.5k
- フォーク
- 5.8k
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 588
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/runtime のほかの issue
-
area-CodeGen-coreclr untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotnet/runtime#138181 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Collections untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
dotnet/runtime#138090 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Text.Json untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dotnet/runtime#138089 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-Setup untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/runtime#137376 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Memory untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dotnet/runtime#137334 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
Add `net10.0`オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
dotnet-outdated/dotnet-outdated#871 ·
メンテナーはふだん 1 日以内に返信
-
triage/untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
unoplatform/uno#26676 ·
メンテナーはふだん 1 日以内に返信
-
.NET bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
jhaizhou-ops/S2Arm#2177 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信