# Perl 5.8.4 以下 の ithread にバグあり - URL: https://www.drk7.jp/MT/archives/000593.html - 公開: 2004.09.17 / 最終更新: 2013.03.24 - カテゴリ: Perl言語 - 著者: drk ![Perl 5.8.4 以下 の ithread にバグありのイメージ(挿絵)](https://www.drk7.jp/media/opt/posts/000593/illust.jpg.w1600.webp) Amazon Search が遅いってコメントを見て、いろいろデバッグ情報を見ていたら、スレッドの生成が怪しいことに気がついた。Amazon Search では1リクエストに対して、検索スレッドが 8 つ並列で起動する仕組みなのですが、全スレッド生成が最短で1秒。最長で50秒もかかっている。 おかしいと思い、いろいろ調べてみると、perl 5.8.4 までの ithread の生成アルゴリズムに不具合があったので、5.8.5 で bugfix したという情報を入手。([詳細はココ](http://search.cpan.org/~nwclark/perl-5.8.5/pod/perl585delta.pod#Selected_Bug_Fixes)) > 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 も再構築するだけで、パフォーマンスが改善されそうです。本日未明、決行しますので、一時的にサービスが停止しますが、ご了承下さい。