Perl 5.8.4 以下 の ithread にバグあり

Perl言語

22年前に書いた記事です。製品やサービスの情報は公開当時のものです。

Perl 5.8.4 以下 の ithread にバグありのイメージ(挿絵)

Amazon Search が遅いってコメントを見て、いろいろデバッグ情報を見ていたら、スレッドの生成が怪しいことに気がついた。Amazon Search では1リクエストに対して、検索スレッドが 8 つ並列で起動する仕組みなのですが、全スレッド生成が最短で1秒。最長で50秒もかかっている。

おかしいと思い、いろいろ調べてみると、perl 5.8.4 までの ithread の生成アルゴリズムに不具合があったので、5.8.5 で bugfix したという情報を入手。(詳細はココ)

Thread creation time could vary wildly between identical runs. This was caused by a poor hashing algorithm in the thread cloning routines, which has now been fixed.

The internals of the ithreads implementation were not checking if OS-level thread creation had failed. threads->create() now returns undef in if thead creation fails instead of crashing perl.

1つ目は、同じ処理を実行してもスレッドの生成時間が大きくばらつくことがあり、原因はスレッドを複製する処理のハッシュアルゴリズムが良くなかったこと、という内容です。

というわけで、perl を 5.8.5 に Upgrade して、mod_perl も再構築するだけで、パフォーマンスが改善されそうです。本日未明、決行しますので、一時的にサービスが停止しますが、ご了承下さい。

最終更新