Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Ruby multithreading

For general discussion related FlowStone

Ruby multithreading

Postby tulamide » Sat Sep 27, 2014 7:48 am

So I read this about Ruby's Thread class:
"Traditional programs have a single thread of execution: the statements or instructions that comprise the program are executed sequentially until the program terminates.

A multithreaded program has more than one thread of execution. Within each thread, statements are executed sequentially, but the threads themselves may be executed in parallel on a multicore CPU, for example. Often on a single CPU machine, multiple threads are not actually executed in parallel, but parallelism is simulated by interleaving the execution of the threads.

Ruby makes it easy to write multi-threaded programs with the Thread class. Ruby threads are a lightweight and efficient way to achieve concurrency in your code."

Multicore CPUs make effective use of threads? Cool, I thought. I made a little example to test it. At least on my multicore PC the additional thread isn't executed in parallel, but just as described simulated by interleaving. Has anyone else played with the Thread class? Is there something wrong in my schematic?
Attachments
thread_test.fsm
(1.01 KiB) Downloaded 790 times
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby multithreading

Postby KG_is_back » Sat Sep 27, 2014 8:35 am

tulamide wrote:So I read this about Ruby's Thread class:
"Traditional programs have a single thread of execution: the statements or instructions that comprise the program are executed sequentially until the program terminates.

A multithreaded program has more than one thread of execution. Within each thread, statements are executed sequentially, but the threads themselves may be executed in parallel on a multicore CPU, for example. Often on a single CPU machine, multiple threads are not actually executed in parallel, but parallelism is simulated by interleaving the execution of the threads.

Ruby makes it easy to write multi-threaded programs with the Thread class. Ruby threads are a lightweight and efficient way to achieve concurrency in your code."

Multicore CPUs make effective use of threads? Cool, I thought. I made a little example to test it. At least on my multicore PC the additional thread isn't executed in parallel, but just as described simulated by interleaving. Has anyone else played with the Thread class? Is there something wrong in my schematic?


the thread parallelism was first introduced to allow multitasking (running multiple programs on a single computer at the same time). However one thread can run only on a single core - I have noticed this myself. I have quadcore computer and windows meter shows 25% while Flowstone shows 100% and crackles like crazy (because the thing is running the thread on a single core, so only quarter of potential is usable). With multithread processing Windows manages the threads so, that it saves energy. That means if you have multiple CPU cheap Threads it opts to execute them on the same core (turning off the rest of the cores), instead of melting the ice caps with all of your 8 overclocked CPUs.
This video of FL studio shows it in action - FL studio is a multithreaded program, yet when CPU load is low, computer opts to turn off some of the cores. http://www.youtube.com/watch?v=DgOV21oi06Q
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Ruby multithreading

Postby tulamide » Sat Sep 27, 2014 8:50 am

KG_is_back wrote:That means if you have multiple CPU cheap Threads it opts to execute them on the same core (turning off the rest of the cores), instead of melting the ice caps with all of your 8 overclocked CPUs.

I see. Screw you, Microsoft. I was just about to dream of a multicore-enabled vst. But hey, maybe if the load is too heavy it might wake up more cores! Hooray, I can still dream of it :mrgreen:
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby multithreading

Postby tester » Sat Sep 27, 2014 12:22 pm

Use multiple and simpler VST plugins instead. :-)

Microsoft isn't that bad, if you look around for alternatives.

Basically, keep in mind also this. What is single-core, are streamy operations. I noticed, that green calculations (I guess specifically related to gui processing) - since they are handled by windows surface - they use other cores as well.

I'm not sure, but maybe (just maybe) - it's possible, that external dll's designed for processing something and giving back the feedback information - would work on other cores too, whole the FS plugin core will stay on single core. I might be wrong, but these seem to me to be separate units.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Ruby multithreading

Postby KG_is_back » Sat Sep 27, 2014 2:10 pm

tester wrote:I'm not sure, but maybe (just maybe) - it's possible, that external dll's designed for processing something and giving back the feedback information - would work on other cores too, whole the FS plugin core will stay on single core. I might be wrong, but these seem to me to be separate units.


tulamide wrote:I see. Screw you, Microsoft. I was just about to dream of a multicore-enabled vst. But hey, maybe if the load is too heavy it might wake up more cores! Hooray, I can still dream of it


"Multithread program"="multicore when needed". There is no point of running the program on 2cores when one is capable of doing it with same efficiency. The whole point of multithread processing is to enable the operating system to have option to spread CPU load to more cores when situation requires. If you push your CPU harder, then naturally one thread will be moved to different core, to ease the load on the first one. Operating system reserves the amount of RAM and maximal CPU load for each thread and moves the threads between cores to execute them with maximum efficiency.

So to make story short. When you have Two threads they may be executed separately, and windows manages them where and when are they executed, be it on a single core when CPU load is low or two cores, when one core is pushed harder and need more cycle headroom. I can see this in FL studio too - when I have my battery mode to "powersaving mode" The CPU load on FL meter rises rapidly, but when it reaches 90% it suddenly jumps down to 50% - Windows enables more CPU cycles for FL studio and turns on second core.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia


Return to General

Who is online

Users browsing this forum: No registered users and 57 guests