Aliasing-motivated concurrency optimizations

オープン
#572 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
20/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
rust
領域
compilers

調査の方向性

Start with the test0-test4 examples in the issue, then read the linked LLVM, C++, and concurrency references to understand the aliasing and ordering claims. Done would require a project-level decision about whether these executions should be allowed or forbidden; the payload names no repository files or runnable tests.

索引モデルが issue の本文から書いたものです。

説明

The following tests capture some of the interactions between aliasing and concurrency.
While the optimizations below may introduce a data-race, any such execution is undefined due to aliasing violations: they'd need to access memory through a reference that's not derived from the &mut.
I don't see any immediate harm in these being allowed, but I found these being allowed by Rust and LLVM-IR interesting, to say the least.

The comments capture what I believe is the "status-quo", everyone should decide for themselves whether they think those executions should be allowed or forbidden:

pub fn test0(b: &mut u32){
  loop {
     let a = AtomicU32::from_mut(b);
     if a.load(Ordering::Relaxed) != 0 { // may be downgraded to non-atomic access
        break;
     }
  }
  *b = 42;
}

pub fn test1(b: &mut u32) -> u32 {
  let x = *b;
  fence(Ordering::Release); // may be re-ordered above load; analogous for store-release
  x
}

pub fn test2(b: &mut u32) {
  *b = 42;
  fence(Ordering::Release); // may be re-ordered above store; analogous for store-release
}

pub fn test3(b: &mut u32) {
  fence(Ordering::Acquire); // analogous for load-acquire
  *b = 42; // may be re-ordered above fence
}

pub fn test4(b: &mut u32) -> u32 {
  fence(Ordering::Acquire); // analogous for load-acquire
  *b // may be re-ordered above fence
}

The examples above are very simple and don't involve allocation APIs.
The following references include many other examples, some of which may be interesting to adapt to Rust.
Particularly interesting are those involving concurrency and "lifetime start"/"end" (memory being allocated/deallocated).

主要言語
言語のデータがありません
スター
760
フォーク
68
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/unsafe-code-guidelines のほかの issue

rust-lang/unsafe-code-guidelines の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。