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

bad Loop causes massive ruby shutdown

For general discussion related FlowStone

bad Loop causes massive ruby shutdown

Postby billv » Sun Nov 03, 2013 12:20 am

I've never seen 'a ruby companant shutdown' happen this bad.... :lol:
While inside main fsm, i added a bad loop...
about 80% of all ruby componants in entire fsm were turned off for excessive processing.
Thought I'd mention it in case there were more noobs out there playing with loops..
Practice loops in isolation.... ;)
ScreenShot307.png
ScreenShot307.png (94.72 KiB) Viewed 15294 times
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: bad Loop causes massive ruby shutdown

Postby RJHollins » Sun Nov 03, 2013 12:29 am

oh yeah ... the 'Red Rings of Fire". :o :shock: :twisted:

One time in particular, I had just saved the FSM. I stuck something into a RUBY and flames everywhere. I ended up reloading the FSM [DO NOT SAVE] . The time to reset everything, it was faster to re-load and try something a little less combustible :lol:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: bad Loop causes massive ruby shutdown

Postby trogluddite » Sun Nov 03, 2013 4:44 am

A "global" reset for the Ruby prim's would be nice though. If you know what bit of code just made the problem, it's often very quick to fix, but going through all of the modules to reset them is really time-consuming.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: bad Loop causes massive ruby shutdown

Postby billv » Sun Nov 03, 2013 5:12 am

trogluddite wrote:going through all of the modules to reset them is really time-consuming.

they were all frozen...couldn't re-open...
brought in new ruby module and tried to capture offending code for reference...froze as well..
I think maybe if i removed all module links..may have unfozen it...
but didn't try...schematic too big...just bailed out...
should have saved it under alt name to re-investigate.... :roll: ...bummer
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: bad Loop causes massive ruby shutdown

Postby Walter Sommerfeld » Sun Nov 03, 2013 8:13 pm

Yeah - it's really a mess - even if u only have 70 rubies in ur schematic :evil: ...

A "global" reset for the Ruby prim's would be nice though.

Yup - we miss this button... :o
User avatar
Walter Sommerfeld
 
Posts: 249
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany

Re: bad Loop causes massive ruby shutdown

Postby tester » Sun Nov 03, 2013 9:08 pm

Try opening the schematic not by clicking on it, but by loading to opened FS. And try to load something else/working first. Maybe this will "reset" the rubyish part.

Just recently ruby started to crash my project on start, but after I did as I said above - I could load the project again. It's probably one of these awkwardnesses...
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: bad Loop causes massive ruby shutdown

Postby billv » Sun Nov 03, 2013 9:46 pm

What about an 'display' in debug window, that shows how much processing
your code is using..... :idea: ??

It's like tester mentioned in other post, it's really hard, being a noob to ruby, to
understand fully what's going on.... :?

Here's a good example of what i mean...

This fist loop runs in about "a blink of an eye'..
Code: Select all
def event i,v

if i == 0 then

for i in 1..1000 do
output 0, i if i % 7==0
end

end
end

In th 2nd copy, I've made 1 change, adding a control variable,
And now it takes a full 2 sec to process.... :!:
Code: Select all
def event i,v

if i == 0 then

for i in 1..1000 do
a = i if i % 7==0
output 0, a
end

end
end


Point is....
It looks like you need "solid" coding skills and "understanding" to get the best out of ruby.

Not knowing stuff like this is making my current project run at 3 times the normal cpu cost....
It's becoming more clear to me that trying to improve my project using ruby is almost pointless..

When i put my current project version up against a older green version.....
the evidence is frightening :shock: ....and just keeps piling up......
Green versions run as smooth as butter...current version is like f##king sandpaper.... :oops:
A million green prims run smoother than a few thousand rubies.... :oops: :oops:

And tester thinks "he's " fustrated....
I'm so close to shutting down and going back to making albums....it's not funny... :lol: :lol:
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: bad Loop causes massive ruby shutdown

Postby tester » Sun Nov 03, 2013 10:45 pm

Yep, your frustration is definately larger than mine :mrgreen:
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: bad Loop causes massive ruby shutdown

Postby Tronic » Mon Nov 04, 2013 8:44 am

You have to take into account that every time an input or an output is fired,
the ruby starts a thread, it processes all in ruby.dll and returns the result of closing the thread.
FS and Ruby are not multithread, all threads are queued and executed.

So in each loop should exclude, the input and output and manage the allocation of them outside of the loop.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: bad Loop causes massive ruby shutdown

Postby trogluddite » Mon Nov 04, 2013 9:16 pm

billv wrote:It looks like you need "solid" coding skills and "understanding" to get the best out of ruby.

But surely that is always true - it would be equally valid to say...
"You need solid trigger prioritising and optimising skills to get the best out of FlowStone's graphical programming language."

All languages have their strengths and weaknesses (and I include "green graphical" as a programming language) - and all programmers have their own unique styles/talents that suit some languages better than others.
Ruby is not a panacea - there are undoubtedly many situations where green primitives will perform better. So neither way is "better" - but each may be "better suited" to either the situation or the programmer.

billv wrote:In th 2nd copy, I've made 1 change, adding a control variable,
And now it takes a full 2 sec to process...

Not quite - you have made two changes - and the second one is the most critical for performance.
In the second example, you have introduced a new variable AND you have taken the "output" command outside of the "if", so it is no longer conditional. (when "if <condition>" is at the end of a line, it affects only that line)

So iIn the first code, you only get an output when you find a multiple of 7; in the second, you send an output for every single iteration - so 7 times as many outputs. As Tronic says, this will cause "grid-lock" at the green output, due to the limited speed of green triggers - so it's most likely the clearing of the output triggers that is slowing things down; there's no reason that the Ruby loop itself should run significantly slower.

There's also something else odd happening. If 'i' is not a multiple of seven, the variable 'a' does not get assigned, and "output 0,a" isn't sending a useful value.
That's because the bit in between "do" and "end" counts as a 'block' of code. Within a 'block' any new variables that get declared are always 'local' to the block, and get destroyed as soon as the block ends. In your loop, the variable 'a' is created and destroyed for every single one of the 1000 iterations, and 6/7 times is never assigned a value.
You can see this in action in this example...
Undeclared in Loop.fsm
(317 Bytes) Downloaded 878 times

Luckily, the conversion to "green" does handle this without a Ruby error - but the 'nil' is converted to the "default" value of zero - so all of those extra output triggers are also sending invalid data. In some cases the undeclared variable would lead to Ruby crashing.

Well OK, so there's some more Ruby weirdness to try and commit to memory - but that's not really the important lesson here.
The real lesson is that you cannot compare the performance of two codes unless they are semantically the same - i.e. the same input conditions produce the same output conditions (with the same timing, if that is important).
And after all this Ruby talk, it's ironic that our biggest friend here would have been the old, faithful "Green Trigger Counter" - it would have shown that the two codes were doing different things very quickly!

On a more practical note, if you want to get some comparative data for the running times of different Ruby codes, you can use this little technique...
Code: Select all
@start_time = Time.now

## CODE TO BE TESTED ##

watch "Elapsed", Time.now - @start_time   #=> Elapsed time in seconds

Note that it's 'Time' with a capital 'T' - a built in Ruby class that reads the system clock. Lower case 'time' is the internal FS Ruby clock, which may not be so accurate (it only updates at 100Hz when there's no audio connection).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Next

Return to General

Who is online

Users browsing this forum: No registered users and 77 guests