perf: buffer WebGL stream writes until flush - #71
Draft
kochounoyume wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
WebGL の
LSStream/IDBStreamで、Writeのたびに累積データ全体を永続化していた実装を、メモリ上でバッファリングしてFlush/Dispose時にまとめて永続化する方式へ変更します。公開 API のシグネチャは変更しません。発生していた問題
従来は各
Writeごとに、それまで書いた全バイト列を LocalStorage / IndexedDB へ保存していました。N個のチャンクを書き込むと永続化する総量は概ね1 + 2 + ... + Nとなり、累積バッファ全体のコピー、Base64変換と JavaScript bridge、IndexedDB の open / transaction / write が繰り返されます。小さいチャンクを多数書くほど write amplification が大きくなります。修正内容
LSStreamはFlush/Disposeで LocalStorage へ保存IDBStreamはFlushAsync/DisposeAsyncで IndexedDB へ保存同期 Dispose / Flush の扱い
IndexedDB の永続化は非同期処理です。dirty な
IDBStreamに対して同期Flush/Disposeを呼ぶと、完了を待てずにデータを失う可能性があります。このPRでは黙って破棄せず例外を送出し、FlushAsyncまたはDisposeAsyncの利用を要求します。LocalStorage は同期 API のため、LSStreamの同期Flush/Disposeで保存できます。影響範囲
IDBStreamの利用側は、書き込み後にFlushAsyncまたはDisposeAsyncが必要検証
dotnet formatを変更 C# ファイルへ実行All test(s) succeededを確認WriteAsyncをDisposeAsyncした結果を再読み込みして検証