昨日からmasuidriveさんと調査してた
eventmachineのバグ
ですが、straceで追いかけてみた結果、
以下の部分が原因である事が分かりました。

em.cpp EventMachine_t::_RunEpollOnce() の最後付近

c>>
timeval tv = {0,0};
EmSelect (0, NULL, NULL, NULL, &tv); // <- これ

return true;
<<--

見るからにWorkaroundっぽいですね。

straceの結果では、正常に実行されてる場合には
ADDからEPOLLINまでのシステムコール呼び出しが以下のような感じなのに対して、

pre>>
write(1, "************** epoll-add: 0.0377"..., 39************** epoll-add: 0.03
7784 - 8
) = 39epoll_ctl(6, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=138272384, u64=1323936545317780646
4}}) = 0
epoll_wait(6, {{EPOLLIN, {u32=138272384, u64=13239365453177806464}}}, 65536, 50)
= 1
gettimeofday({1230425221, 603705}, NULL) = 0
write(1, "************** epoll-read: 0.020"..., 40************** epoll-read: 0.0
20716 - 8
<<--

異常時には以下のように謎のselectが発生していました。

pre>>
write(1, "************** epoll-add: 0.0295"..., 39************** epoll-add: 0.029586 - 8
) = 39
epoll_ctl(6, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=138272384, u64=1323936545317780646
4}}) = 0
epoll_wait(6, {}, 65536, 50) = 0
select(0, NULL, NULL, NULL, {0, 0}) = 0 (Timeout)
time(NULL) = 1230425221
gettimeofday({1230425221, 787115}, NULL) = 0
epoll_wait(6, {}, 65536, 50) = 0
select(0, NULL, NULL, NULL, {0, 0}) = 0 (Timeout)time(NULL) = 1230425221
gettimeofday({1230425221, 839105}, NULL) = 0
epoll_wait(6, {{EPOLLIN, {u32=138272384, u64=13239365453177806464}}}, 65536, 50) = 1
gettimeofday({1230425221, 843713}, NULL) = 0
write(1, "************** epoll-read: 0.110"..., 40************** epoll-read: 0.1
10337 - 8
<<--

どうやらこの謎のEmSelect呼び出しはビジーループ対策のために
挿入されているらしいのですが、以下のような形に直すと問題が
発生しなくなるようです。

c>>
//timeval tv = {0,0};
//EmSelect (0, NULL, NULL, NULL, &tv);
#ifdef BUILD_FOR_RUBY
if (!rb_thread_alone()) {
rb_thread_schedule();
}
#endif
<<--

eventmachineのticketにpatchが上がっている
ので、近いうちに修正されるかもしれません。

ということで、ひとまずお疲れさまでしたー>masuidriveさん

posted by genki genki on Sun 28 Dec 2008 at 10:18 with 0 comments
Contents rssrss
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Droonga関連の記事のまとめ
RuntimeErrorの特定のメッセージに限定してrescueする方法
jQueryでscriptタグを実行せずにappendする
Tags
coffeescriptdefergroongajsmemonodenodejs
Comments rssrss
guest guest: Para muchos turistas, el transporte publico y la l... 05/15 18:22
guest guest: Para muchos turistas, el transporte publico y la l... 05/15 18:22
http://www.google.com http://www.google.com: When I initially commented I clicked the "Notify m... 05/15 17:52
https://linklist.bio/pulitotologin https://linklist.bio/pulitotologin: Hi! I know this is kind of off-topic however I nee... 05/15 17:22
https://bayra.market/produkty-pitaniya-ru/ryba-i-moreprodukty/preservy-rybnye/seld-file-kusochki-v-mayoneze-160-g/ https://bayra.market/produkty-pitaniya-ru/ryba-i-moreprodukty/preservy-rybnye/seld-file-kusochki-v-mayoneze-160-g/: Цена такого предложения полностью оправдывает влож... 05/15 16:43
https://www.integramais.com.br/2026/04/25/discover-kfc-promotions-and-deals-in-singapore-on-kaizenaire-com-2/ https://www.integramais.com.br/2026/04/25/discover-kfc-promotions-and-deals-in-singapore-on-kaizenaire-com-2/: Kaizenaire.com blazes a trail іn Singapore as thе ... 05/15 13:36
https://aula.centroagoraformacion.com/blog/index.php?entryid=486828 https://aula.centroagoraformacion.com/blog/index.php?entryid=486828: Kaizenaire.com іs Singapore'ѕ leading location fօr... 05/15 12:53
https://Anomaastudio.in/groups/affordable-luxury-singapore-furniture-shopping-strategies-for-2026/ https://Anomaastudio.in/groups/affordable-luxury-singapore-furniture-shopping-strategies-for-2026/: How t᧐ Picck the Right Mattress in Singapore – Α... 05/15 12:09