Re: Concurent (using threads) slower than sequential -doubt



Thank all of you (Matz, Charles and Robert)

Just one more doubt.....

Since the threads I created really resides as an array that holds
threads object I tried to access each one by using [ ] notation:

for t in m_threads
print t[:INDEX], "\n"
end

The interpreter does not throw any error, but results always indicate:
nil
nil
nil

I tried to verify if they are still running:

Thread.list.each{|t| p t}

Results were:
#<Thread:0x29c5fc0 run>
#<Thread:0x29c6100 run>
#<Thread:0x29c6240 run>
#<Thread:0x294c74c run>

So indeed they are running... the doubt is...why I can't access the
content of the array?
In fact in the statement
m_threads.each{ |t| t.join; result = t[:INDEX] + result; }

I just can compute result variable only after executing t.join..... if
I take out the t.join statement the interpreter throws an error:

PbaThreads.rb:10 : undefined method `+' for nil:NilClass (NoMethodError)

Could you clarify this, please.

Best Regards




Robert Klemme wrote:
2008/10/6 Yukihiro Matsumoto <matz@xxxxxxxxxxxxx>

In message "Re: Concurent (using threads) slower than sequential -doubt"
on Mon, 6 Oct 2008 12:40:08 +0900, Carlos Ortega <caof2005@xxxxxxxxx> writes:

|As you see, the thread based program run slower.
|I thought that by using threads it will be faster, but it didn't....Why
|is it slower?

Threads require context switching, so that they tend to run slower,
especially green threads like Ruby 1.8 has.

There is another issue which may easily have a more serious impact:
since all three files reside in the same directory they are read from
the same physical device (most likely a local (S)ATA disk). And since
these files are large chances are that they are spread over the disk
and do not fit into the operating systems buffer cache. This will lead
to reasonably more head movement and less efficient disk caching than
the sequential approach.

Kind regards

robert

--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: Need feedback on the A5200 storage array....
    ... they don't have the money for a big Hitachi array or a fast FC array with ... Use RAID5 on that kind of hardware. ... ten years or so) that had internal RAID5 controllers. ... I can't simply yank a disk and read its ...
    (comp.unix.solaris)
  • Re: HP EVA4000 / IBM DS4300 / EMC CX3-20/40
    ... Both EMC and EVA are great arrays and they will serve you well. ... disk array with the virtual raidsets on top. ... So, the system admin, and the DBAs had to create and manage lots of ...
    (comp.arch.storage)
  • Re: RAID 5 corruption, RAID 1 more stable?
    ... corruption to either the RAID array itself or the file system. ... The disk array to suffer so many errors (for example disk errors ... There is nothing the disk array can do if the host is broken and ...
    (comp.arch.storage)
  • Bug+fix: PDC20271 RAID detection fails
    ... My array was not detected by my kernel. ... the PDC RAID superblock, that is located at the start ... of the last track on the disk. ... is a multiple of track size and if not, ...
    (comp.os.linux.hardware)
  • FreeBSD 4.8, ASR2120, SMP, degraded RAID1/mirror => storage failure
    ... upon a RAID array degradation event (a disk is ... The same happens upon boot with a rebuilding/degraded array ... Attached is a tarball with debugging logs. ...
    (freebsd-questions)