The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Comparing lightweight threads

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
Comparing lightweight threads Posted: Mar 24, 2008 11:12 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: Comparing lightweight threads
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

The Computer Language Benchmarks Game includes a benchmark that measures context switch performance. The entries can be classified into three categories:

  1. those that rely on lightweight threads, namely Haskell GHC, Erlang HiPE and Mozart/Oz. I don't know whether Smalltalk VisualWorks and Scala belong here too; their performance is far from the top three entries.
  2. those that use POSIX threads, with or without actual parallelism, including most other entries
  3. Ruby, a category of it own (?): very expensive user-mode mode threads with no parallelism

The OCaml entry is amongst the fastest pthread-based ones, but still markedly slower than the top entry, by around an order of magnitude. The version I wrote some time ago, based on the Lwt cooperative lightweight thread library, is close in performance to GHC. Some analysis reveals interesting facts about GHC's concurrency support and Lwt.

Performance

Here are the figures I get on a dual-core AMD Athlon 64 X2 6000+ in 32 bit mode (Why 32 and not 64? Because it's faster in this benchmark; 64 bit pointers are heavy and we get nothing in return in this case.)

implementationmemory usagetime (s)
Haskell GHC 6.8.22680KB1.22
Haskell GHC 6.8.2 -threaded, -N23300KB15.27
Haskell GHC 6.8.2 -threaded, -N12760KB1.9
Erlang HiPE5996KB3.96
OCaml ocamlopt 1024Kword minor heap5178KB1.85
OCaml ocamlopt 256Kword minor heap2016KB2.05
OCaml ocamlopt 64Kword minor heap1228KB3.06
OCaml ocamlopt 32Kword minor heap970KB4.24

The Haskell code was compiled with -O2 (GHC 8.8.2); for Erlang, I used erlc +native +"{hipe, [o3]}" (Erlang R12B-1).

GC overhead

The OCaml version is clearly GC bound, and performance increases as the minor heap is enlarged, decreasing the amount of GC work. Whereas with the default 256KB heap the Erlang program is slightly faster, when OCaml is allowed to use comparable amounts of memory, it is over twice as fast.

speed.png
Read more...

Read: Comparing lightweight threads

Topic: Presenting Code Previous Topic   Next Topic Topic: Ah, the joy of commit

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use