Hatena::ブログ(Diary)

”><xmp>TokuLog 改メ tokuhirom’s blog このページをアンテナに追加 RSSフィード

summary of cons/pros about ithreads/coro/fork(2)

rafl wishes gfuji and tokuhirom would blog in english

などといわれたので、ためしに英語で1エントリだけかいてみるよ。

Perl5 has some ways for concurrent programming.This article is research summary for that tools.

summary

coroithreadsfork(2)
speed for creating new onefastslow fast
memory footprint greattoo bad great*1
ease to use greatbad bad
cpan friendly? good bad great
stability good bad great
works well on multiple CPUs?bad bad great
easy to communicate one another?greatgoodbad
black magic !!! - -

detail

ithreads
fork(2)
  • save memories by Copy on Write mechanism(on *nix systems)
  • forked processes are very stable and CPAN friendly =)
  • forked processes works on multiple CPUs.This is good for modern servers.
  • Programming management forked processes is hard.
    • I don't want to fork Apache!
    • I hate zombie process...
Coro
  • Coro is black magic.
  • Coro's coroutine is very lightweight!
  • Coro doesn't use a lot of memory.
  • Programming with Coro is very easy.
  • Very easy to communicate between coros.

Conclusion

  • I don't want to use ithreads.
  • fork(2) is good enough for most cases
    • CPU intensive problems should use fork(2)
  • Coro is good for I/O intensive problems
    • like a crawler
  • Coro is good for web applications
    • send a queries for RDBMS concurrently
    • Coro can pass the result of queries easily =)
    • etc.

*1:by Copy on Write

投稿したコメントは管理者が承認するまで公開されません。

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/tokuhirom/20090630/1246324092