並行実行可能なスレッド数を制限 & 外部プロセス由来のエラー時にリトライ #6
Merged
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.
並列実行可能なスレッド数を制限
10,000スレッドぐらいから同時にcontext.evalを呼ぶとErrno::ECONNREFUSEDのエラーが出る
実用上10,000並列で呼び出したいことはほぼ無さそうなので、並列実行可能数に制限をかけることで回避したい
TODO:
外部プロセス由来のエラー時にリトライ
現状、実行中にNode.jsのプロセスが何らかの理由で落ちたりSocketが閉じたりするとそのままRuby側も落ちる実装になっている
execjsデフォルトのNode.jsランタイムなどではexec毎にプロセスを起動しているのでこのような予期しない問題はほぼ起きないが、pcruntimeのように単一のプロセスを長時間使い回す実装ではこのような問題が起こる確率が比較的高いため、もしも起こった場合のリトライ処理を実装した