Skip to content

perf: parallelize slice alignment with multiprocessing#3

Open
Ryo722 wants to merge 1 commit intorotejin:masterfrom
Ryo722:improve/parallel-alignment
Open

perf: parallelize slice alignment with multiprocessing#3
Ryo722 wants to merge 1 commit intorotejin:masterfrom
Ryo722:improve/parallel-alignment

Conversation

@Ryo722
Copy link
Copy Markdown

@Ryo722 Ryo722 commented Mar 30, 2026

Summary

スライスの位置合わせ処理を multiprocessing.Pool で並列化し、マルチコアCPUでの処理速度を向上させます。

背景

  • 現在の実装では、各スライスのAKAZE/ORB特徴点検出・マッチングを逐次処理しています
  • 各スライスの処理は完全に独立しているため、並列化が可能です
  • PythonのGIL制約により threading では真の並列化ができないため、multiprocessing を使用します

効果

  • 2x2グリッド(3スライス): 約2-3倍の高速化
  • 3x3グリッド(8スライス): さらに大きな改善

Changes

  • aligner.py: _align_single_slice() トップレベル関数を追加(multiprocessingのpickle要件対応)
  • mask_composer.py: SliceAlignWorker.run()Pool.map() による並列処理に変更

Test plan

  • 2x2グリッドで位置合わせが正常に完了すること
  • 3x3グリッドで位置合わせが正常に完了すること
  • 位置合わせの結果品質が変わらないこと(逐次処理と同一結果)
  • macOS / Windows / Linux で動作すること

Use multiprocessing.Pool to run AKAZE/ORB feature detection and
matching in parallel across slices. This bypasses Python's GIL
limitation and can achieve near-linear speedup on multi-core CPUs.

On a 2x2 grid (3 diff slices), this typically yields 2-3x speedup.
On a 3x3 grid (8 diff slices), the improvement is more significant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant