Use zval storage for php://memory stream
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code increases the peak memory usage of PHP twice:
$content = str_repeat('hello', 50000);
$h = fopen('php://memory', 'r+');
fwrite($h, $content);
The reason is that PHP cannot currently use copy-on-write when writing to the stream.
This is something that can be worked around by using a custom stream wrapper that keeps data in a zval, as done in e.g.
https://github.com/Nyholm/psr7/pull/230
Using this proved useful for strings longer than ~200K. For smaller strings, using a custom stream wrapper has a higher cost than the memcopy (see https://github.com/Nyholm/psr7/pull/241).
Could it be possible to improve php://memory (and possibly php://temp) to make it use a zval storage to benefit from copy-on-write?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず php://memory ストリームの実装を追跡し、そのストレージ動作を issue で説明されている zval ベースのカスタムラッパーと比較します。php://temp をどのように扱うべきか、また約 200K のサイズ上のトレードオフが設計にどのような影響を与えるかを判断します。ストリームが copy-on-write の恩恵を受けつつ、より小さい文字列のパフォーマンスを低下させないことが完了の条件です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend, performance
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100