High CPU load when using orocos state machines

Hi,

I have a big problem with the CPU load, when using Orocos state machines. My application consists of 3 threads. 2 of them run cyclic (period: less than 1 ms). The third is a non periodic task (period 0), which is managed over an Orocos hierarchical state machine. The state machine is triggered over event ports, which will be set from the 2 periodic threads. The functionality of the state machine works fine. I load, activate and start all state machines during configuration time of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it's nearly 90%. The load jumps between both CPUs.
When I replace the reaction to the event ports via the Orocos state machine with direct callback functions for each port the CPU load decreases to 5%.
I don't calculate much. So it's completely strange and inadmissible that the CPU load is so high when using the state machine. The only thing, which could increase the CPU load, are the context switches between the threads.

Does anyone have any idea why the state machines increase the CPU load so much? Is an Orocos state machine really executed in the thread context, where I load the state machine or will be created another thread for the state machine? Are there any limits for the period of Orocos threads or the usage of Orocos state machines? (Is less than 1 ms for more than one thread even working? Is an event reaction over state machines working with a high event rate?) Do exist timing analysis about the cost of Orocos thread and Orocos state machine usage?

Thanks a lot for any help.

Greetings
Sandra

High CPU load when using orocos state machines

Hi Peter,
I’m using the Orocos version 2.7 rc9.
So rtt state machines could really be a problem when I run them with less than 1 ms?
Are the event ports (or all ports / orocos) also only designed to run efficiently at 1 ms?

I appended the rtt state machine and for demonstration an extract of the calculations which are called in the state machine. All methods which are called in the state machine are implemented in the component which loads the state machine. When I run the application the state machine will be set to PROCESSING and MODULATING. sigCycleInport will be triggered every 500 ms. It doesn’t matter if I only set one state or if I delete the hierarchical state machines (Process and Modulate) and directly calculate in the root state machine. The CPU load stays much too high for that little example calculation. Otherwise the state machine does exactly what it should.

Sandra

Von: Peter Soetens [mailto:peter [..] ...]
Gesendet: Montag, 23. Juni 2014 12:36
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

Hi Sandra,

Please always show a short code example + orocos version, since this eliminates us second guessing the scripting language you're using.

The classic rtt state machines are designed to run efficiently at 1ms... They were made to run synchronously with your realtime controller.

There could be a regression in the event processing code which the unit tests dont catch. So please provide an example.

With respect to the rfsm vs classical fsm, both can be made equally hard real-time, but it requires more careful setup/programming with rfsm.

Peter

Op maandag 23 juni 2014 heeft Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>> het volgende geschreven:
Hi,

I have a big problem with the CPU load, when using Orocos state machines. My application consists of 3 threads. 2 of them run cyclic (period: less than 1 ms). The third is a non periodic task (period 0), which is managed over an Orocos hierarchical state machine. The state machine is triggered over event ports, which will be set from the 2 periodic threads. The functionality of the state machine works fine. I load, activate and start all state machines during configuration time of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
When I replace the reaction to the event ports via the Orocos state machine with direct callback functions for each port the CPU load decreases to 5%.
I don’t calculate much. So it’s completely strange and inadmissible that the CPU load is so high when using the state machine. The only thing, which could increase the CPU load, are the context switches between the threads.

Does anyone have any idea why the state machines increase the CPU load so much? Is an Orocos state machine really executed in the thread context, where I load the state machine or will be created another thread for the state machine? Are there any limits for the period of Orocos threads or the usage of Orocos state machines? (Is less than 1 ms for more than one thread even working? Is an event reaction over state machines working with a high event rate?) Do exist timing analysis about the cost of Orocos thread and Orocos state machine usage?

Thanks a lot for any help.

Greetings
Sandra

--
Peter Soetens, Managing Director
+32 473 170 240
Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM
www.intermodalics.eu<http://www.intermodalics.eu>

High CPU load when using orocos state machines

On Jun 23, 2014, at 07:34 , Sandra Beyer <sandra [dot] beyer [..] ...> wrote:

> Hi Peter,
> I’m using the Orocos version 2.7 rc9.
> So rtt state machines could really be a problem when I run them with less than 1 ms?

We use RTT state machines at 2 ms with virtually no load, so I doubt that it's the SM implementation.

> Are the event ports (or all ports / orocos) also only designed to run efficiently at 1 ms?

We don't use these so I can't comment.

Have you tried running at a slower rate (e.g. 10ms) to see whether the load changes?

> I appended the rtt state machine and for demonstration an extract of the calculations which are called in the state machine. All methods which are called in the state machine are implemented in the component which loads the state machine. When I run the application the state machine will be set to PROCESSING and MODULATING. sigCycleInport will be triggered every 500 ms. It doesn’t matter if I only set one state or if I delete the hierarchical state machines (Process and Modulate) and directly calculate in the root state machine. The CPU load stays much too high for that little example calculation. Otherwise the state machine does exactly what it should.

Do you manually trigger the state machine component to run anywhere except using event ports?

Personally, I'd recommend logging when and why your component is waking up. It might help show a pattern.
S

>
> Sandra
>
> Von: Peter Soetens [mailto:peter [..] ...]
> Gesendet: Montag, 23. Juni 2014 12:36
> An: Sandra Beyer
> Cc: orocos-users
> Betreff: Re: [Orocos-users] High CPU load when using orocos state machines
>
> Hi Sandra,
>
> Please always show a short code example + orocos version, since this eliminates us second guessing the scripting language you're using.
>
> The classic rtt state machines are designed to run efficiently at 1ms... They were made to run synchronously with your realtime controller.
>
> There could be a regression in the event processing code which the unit tests dont catch. So please provide an example.
>
> With respect to the rfsm vs classical fsm, both can be made equally hard real-time, but it requires more careful setup/programming with rfsm.
>
> Peter
>
> Op maandag 23 juni 2014 heeft Sandra Beyer <sandra [dot] beyer [..] ...> het volgende geschreven:
> Hi,
>
> I have a big problem with the CPU load, when using Orocos state machines. My application consists of 3 threads. 2 of them run cyclic (period: less than 1 ms). The third is a non periodic task (period 0), which is managed over an Orocos hierarchical state machine. The state machine is triggered over event ports, which will be set from the 2 periodic threads. The functionality of the state machine works fine. I load, activate and start all state machines during configuration time of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
> When I replace the reaction to the event ports via the Orocos state machine with direct callback functions for each port the CPU load decreases to 5%.
> I don’t calculate much. So it’s completely strange and inadmissible that the CPU load is so high when using the state machine. The only thing, which could increase the CPU load, are the context switches between the threads.
>
> Does anyone have any idea why the state machines increase the CPU load so much? Is an Orocos state machine really executed in the thread context, where I load the state machine or will be created another thread for the state machine? Are there any limits for the period of Orocos threads or the usage of Orocos state machines? (Is less than 1 ms for more than one thread even working? Is an event reaction over state machines working with a high event rate?) Do exist timing analysis about the cost of Orocos thread and Orocos state machine usage?
>
>
> Thanks a lot for any help.
>
> Greetings
> Sandra

High CPU load when using orocos state machines

Hi Sandra,

Please always show a short code example + orocos version, since this
eliminates us second guessing the scripting language you're using.

The classic rtt state machines are designed to run efficiently at
1ms... They were made to run synchronously with your realtime
controller.

There could be a regression in the event processing code which the
unit tests dont catch. So please provide an example.

With respect to the rfsm vs classical fsm, both can be made equally
hard real-time, but it requires more careful setup/programming with
rfsm.

Peter

On Mon, Jun 23, 2014 at 9:15 AM, Sandra Beyer <sandra [dot] beyer [..] ...> wrote:
> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state machines. My
> application consists of 3 threads. 2 of them run cyclic (period: less than 1
> ms). The third is a non periodic task (period 0), which is managed over an
> Orocos hierarchical state machine. The state machine is triggered over event
> ports, which will be set from the 2 periodic threads. The functionality of
> the state machine works fine. I load, activate and start all state machines
> during configuration time of the thread. But when I check the CPU load of my
> PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state machine
> with direct callback functions for each port the CPU load decreases to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible that the
> CPU load is so high when using the state machine. The only thing, which
> could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load so
> much? Is an Orocos state machine really executed in the thread context,
> where I load the state machine or will be created another thread for the
> state machine? Are there any limits for the period of Orocos threads or the
> usage of Orocos state machines? (Is less than 1 ms for more than one thread
> even working? Is an event reaction over state machines working with a high
> event rate?) Do exist timing analysis about the cost of Orocos thread and
> Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

High CPU load when using orocos state machines

Hi Sandra,

are you sending events at every cycle of the two periodic components? Have
you got a "doo" function defined for one of the states of the fsm in which
you have inserted a while(true) loop with a breaking condition but without
using "yield()"?

Nicola

2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:

> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state machines.
> My application consists of 3 threads. 2 of them run cyclic (period: less
> than 1 ms). The third is a non periodic task (period 0), which is managed
> over an Orocos hierarchical state machine. The state machine is triggered
> over event ports, which will be set from the 2 periodic threads. The
> functionality of the state machine works fine. I load, activate and start
> all state machines during configuration time of the thread. But when I
> check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps
> between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state
> machine with direct callback functions for each port the CPU load decreases
> to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible that
> the CPU load is so high when using the state machine. The only thing, which
> could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load so
> much? Is an Orocos state machine really executed in the thread context,
> where I load the state machine or will be created another thread for the
> state machine? Are there any limits for the period of Orocos threads or the
> usage of Orocos state machines? (Is less than 1 ms for more than one thread
> even working? Is an event reaction over state machines working with a high
> event rate?) Do exist timing analysis about the cost of Orocos thread and
> Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>

High CPU load when using orocos state machines

Oooh I just saw I wrote the wrong time. The periodic event is triggered every 500 nano seconds and not mili seconds. Really sorry. But I just tried to run it slower (2 miliseconds) and it doesn't make any difference. So it’s probably not a problem with the frequency of the triggering port. Thanks for the trace information. I will try this.

I meant the state machine is triggered faster than every 1 ms via an event port. All calculations are done till the next trigger.

Sandra

----------------------------------------------------------------
Software-Entwicklung | Raum 59 | -727

-----Ursprüngliche Nachricht-----
Von: Peter Soetens [mailto:peter [..] ...]
Gesendet: Montag, 23. Juni 2014 14:09
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

On Mon, Jun 23, 2014 at 1:34 PM, Sandra Beyer <sandra [dot] beyer [..] ...> wrote:
> Hi Peter,
>
> I’m using the Orocos version 2.7 rc9.
>
> So rtt state machines could really be a problem when I run them with
> less than 1 ms?

Do you mean less frequent or less cycle time ?

>
> Are the event ports (or all ports / orocos) also only designed to run
> efficiently at 1 ms?

'Starting from 1ms'. I have yet to see an application where the response time needs to be < 1ms

I was implying that when it works at 1ms, it certainly works at 10ms or 500ms.

>
>
>
> I appended the rtt state machine and for demonstration an extract of
> the calculations which are called in the state machine. All methods
> which are called in the state machine are implemented in the component
> which loads the state machine. When I run the application the state
> machine will be set to PROCESSING and MODULATING. sigCycleInport will
> be triggered every 500 ms. It doesn’t matter if I only set one state
> or if I delete the hierarchical state machines (Process and Modulate)
> and directly calculate in the root state machine. The CPU load stays
> much too high for that little example calculation. Otherwise the state machine does exactly what it should.

If the state machine only runs twice a second, something really strange is going on as it's supposed to be able to do that 500x faster as well.

Since the component is non-periodic, I would suppose that it is being re-triggered way too often.

You can turn on debugging of your state machine with

RTT::scripting::ScriptingService::shared_ptr ss = dynamic_pointer_cast<RTT::scripting::ScriptingService>(
this->provides("scripting") );
StateMachine::shared_ptr sm =ss->getStateMachine("rootFSM");
sm->trace(true);
sm = ss->getStateMachine("rootFSM.processFSM")
sm->trace(true);

In your configureHook(). Hope this clarifies what is going on...

Peter

>
>
>
> Sandra
>
>
>
> Von: Peter Soetens [mailto:peter [..] ...]
> Gesendet: Montag, 23. Juni 2014 12:36
>
>
> An: Sandra Beyer
> Cc: orocos-users
> Betreff: Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
> Hi Sandra,
>
>
>
> Please always show a short code example + orocos version, since this
> eliminates us second guessing the scripting language you're using.
>
>
>
> The classic rtt state machines are designed to run efficiently at 1ms...
> They were made to run synchronously with your realtime controller.
>
>
>
> There could be a regression in the event processing code which the
> unit tests dont catch. So please provide an example.
>
>
>
> With respect to the rfsm vs classical fsm, both can be made equally
> hard real-time, but it requires more careful setup/programming with rfsm.
>
>
>
> Peter
>
> Op maandag 23 juni 2014 heeft Sandra Beyer <sandra [dot] beyer [..] ...>
> het volgende geschreven:
>
> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state
> machines. My application consists of 3 threads. 2 of them run cyclic
> (period: less than 1 ms). The third is a non periodic task (period 0),
> which is managed over an Orocos hierarchical state machine. The state
> machine is triggered over event ports, which will be set from the 2
> periodic threads. The functionality of the state machine works fine. I
> load, activate and start all state machines during configuration time
> of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state
> machine with direct callback functions for each port the CPU load decreases to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible
> that the CPU load is so high when using the state machine. The only
> thing, which could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load
> so much? Is an Orocos state machine really executed in the thread
> context, where I load the state machine or will be created another
> thread for the state machine? Are there any limits for the period of
> Orocos threads or the usage of Orocos state machines? (Is less than 1
> ms for more than one thread even working? Is an event reaction over
> state machines working with a high event rate?) Do exist timing
> analysis about the cost of Orocos thread and Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
>
>
> --
> Peter Soetens, Managing Director
> +32 473 170 240
> Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM
> www.intermodalics.eu

--
Peter Soetens, Managing Director
+32 473 170 240
Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM www.intermodalics.eu

High CPU load when using orocos state machines

Again a timing mistake. Of course ns would be much too fast. 0.5 ms is the right cycle time of my application but we want to go down to 0.2 ms. (Sorry - Seems I'm a little bit confused today -.-)
So far it really seems that my state machine makes the big load. I found a configuration where 2 ms work fine. So I probably have to avoid the state machines.

Thanks for your help and the detailed tips for debugging.

Sandra

-----Ursprüngliche Nachricht-----
Von: orocos-users-bounces [..] ... [mailto:orocos-users-bounces [..] ...] Im Auftrag von Sandra Beyer
Gesendet: Montag, 23. Juni 2014 14:21
An: 'Peter Soetens'
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

Oooh I just saw I wrote the wrong time. The periodic event is triggered every 500 nano seconds and not mili seconds. Really sorry. But I just tried to run it slower (2 miliseconds) and it doesn't make any difference. So it’s probably not a problem with the frequency of the triggering port. Thanks for the trace information. I will try this.

I meant the state machine is triggered faster than every 1 ms via an event port. All calculations are done till the next trigger.

Sandra

----------------------------------------------------------------
Software-Entwicklung | Raum 59 | -727

-----Ursprüngliche Nachricht-----
Von: Peter Soetens [mailto:peter [..] ...]
Gesendet: Montag, 23. Juni 2014 14:09
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

On Mon, Jun 23, 2014 at 1:34 PM, Sandra Beyer <sandra [dot] beyer [..] ...> wrote:
> Hi Peter,
>
> I’m using the Orocos version 2.7 rc9.
>
> So rtt state machines could really be a problem when I run them with
> less than 1 ms?

Do you mean less frequent or less cycle time ?

>
> Are the event ports (or all ports / orocos) also only designed to run
> efficiently at 1 ms?

'Starting from 1ms'. I have yet to see an application where the response time needs to be < 1ms

I was implying that when it works at 1ms, it certainly works at 10ms or 500ms.

>
>
>
> I appended the rtt state machine and for demonstration an extract of
> the calculations which are called in the state machine. All methods
> which are called in the state machine are implemented in the component
> which loads the state machine. When I run the application the state
> machine will be set to PROCESSING and MODULATING. sigCycleInport will
> be triggered every 500 ms. It doesn’t matter if I only set one state
> or if I delete the hierarchical state machines (Process and Modulate)
> and directly calculate in the root state machine. The CPU load stays
> much too high for that little example calculation. Otherwise the state machine does exactly what it should.

If the state machine only runs twice a second, something really strange is going on as it's supposed to be able to do that 500x faster as well.

Since the component is non-periodic, I would suppose that it is being re-triggered way too often.

You can turn on debugging of your state machine with

RTT::scripting::ScriptingService::shared_ptr ss = dynamic_pointer_cast<RTT::scripting::ScriptingService>(
this->provides("scripting") );
StateMachine::shared_ptr sm =ss->getStateMachine("rootFSM");
sm->trace(true);
sm = ss->getStateMachine("rootFSM.processFSM")
sm->trace(true);

In your configureHook(). Hope this clarifies what is going on...

Peter

>
>
>
> Sandra
>
>
>
> Von: Peter Soetens [mailto:peter [..] ...]
> Gesendet: Montag, 23. Juni 2014 12:36
>
>
> An: Sandra Beyer
> Cc: orocos-users
> Betreff: Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
> Hi Sandra,
>
>
>
> Please always show a short code example + orocos version, since this
> eliminates us second guessing the scripting language you're using.
>
>
>
> The classic rtt state machines are designed to run efficiently at 1ms...
> They were made to run synchronously with your realtime controller.
>
>
>
> There could be a regression in the event processing code which the
> unit tests dont catch. So please provide an example.
>
>
>
> With respect to the rfsm vs classical fsm, both can be made equally
> hard real-time, but it requires more careful setup/programming with rfsm.
>
>
>
> Peter
>
> Op maandag 23 juni 2014 heeft Sandra Beyer <sandra [dot] beyer [..] ...>
> het volgende geschreven:
>
> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state
> machines. My application consists of 3 threads. 2 of them run cyclic
> (period: less than 1 ms). The third is a non periodic task (period 0),
> which is managed over an Orocos hierarchical state machine. The state
> machine is triggered over event ports, which will be set from the 2
> periodic threads. The functionality of the state machine works fine. I
> load, activate and start all state machines during configuration time
> of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state
> machine with direct callback functions for each port the CPU load decreases to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible
> that the CPU load is so high when using the state machine. The only
> thing, which could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load
> so much? Is an Orocos state machine really executed in the thread
> context, where I load the state machine or will be created another
> thread for the state machine? Are there any limits for the period of
> Orocos threads or the usage of Orocos state machines? (Is less than 1
> ms for more than one thread even working? Is an event reaction over
> state machines working with a high event rate?) Do exist timing
> analysis about the cost of Orocos thread and Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
>
>
> --
> Peter Soetens, Managing Director
> +32 473 170 240
> Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM
> www.intermodalics.eu

--
Peter Soetens, Managing Director
+32 473 170 240
Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM www.intermodalics.eu
--
Orocos-Users mailing list
Orocos-Users [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

High CPU load when using orocos state machines

2014-06-23 16:27 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
> Again a timing mistake. Of course ns would be much too fast. 0.5 ms is the right cycle time of my application but we want to go down to 0.2 ms. (Sorry - Seems I'm a little bit confused today -.-)
> So far it really seems that my state machine makes the big load. I found a configuration where 2 ms work fine. So I probably have to avoid the state machines.

Isn't it surprising to see such timing entering the "component" level
? Your state machine is representing your component behavior. I know
application that need very fast time response, but under the ms I
wonder if it's not a too "high" level of code to go in the component.

I think your code running at 0,2ms should go in a "driver". I you use
Orocos and Ros, I suppose you have a linux to run this, and at those
timings, you can't stay reasonably in user space.

In theory, it would be possible to do a component to do the hardware
job, or to design driver as state machines, but certainly not with a
scripting language such as lua or orocos scripts.

If you want to go througth low level state machine, you have to choose
a light state machine implementation. For instance Yakindu may help :
http://statecharts.org/
(it's a model based ecosystem, but the generated code is ligth and
easy to lembed)

>
> Thanks for your help and the detailed tips for debugging.
>
> Sandra
>
>
> -----Ursprüngliche Nachricht-----
> Von: orocos-users-bounces [..] ... [mailto:orocos-users-bounces [..] ...] Im Auftrag von Sandra Beyer
> Gesendet: Montag, 23. Juni 2014 14:21
> An: 'Peter Soetens'
> Cc: orocos-users
> Betreff: Re: [Orocos-users] High CPU load when using orocos state machines
>
> Oooh I just saw I wrote the wrong time. The periodic event is triggered every 500 nano seconds and not mili seconds. Really sorry. But I just tried to run it slower (2 miliseconds) and it doesn't make any difference. So it’s probably not a problem with the frequency of the triggering port. Thanks for the trace information. I will try this.
>
> I meant the state machine is triggered faster than every 1 ms via an event port. All calculations are done till the next trigger.
>
> Sandra
>
> ----------------------------------------------------------------
> Software-Entwicklung | Raum 59 | -727
>
> -----Ursprüngliche Nachricht-----
> Von: Peter Soetens [mailto:peter [..] ...]
> Gesendet: Montag, 23. Juni 2014 14:09
> An: Sandra Beyer
> Cc: orocos-users
> Betreff: Re: [Orocos-users] High CPU load when using orocos state machines
>
> On Mon, Jun 23, 2014 at 1:34 PM, Sandra Beyer <sandra [dot] beyer [..] ...> wrote:
>> Hi Peter,
>>
>> I’m using the Orocos version 2.7 rc9.
>>
>> So rtt state machines could really be a problem when I run them with
>> less than 1 ms?
>
> Do you mean less frequent or less cycle time ?
>
>>
>> Are the event ports (or all ports / orocos) also only designed to run
>> efficiently at 1 ms?
>
> 'Starting from 1ms'. I have yet to see an application where the response time needs to be < 1ms
>
> I was implying that when it works at 1ms, it certainly works at 10ms or 500ms.
>
>>
>>
>>
>> I appended the rtt state machine and for demonstration an extract of
>> the calculations which are called in the state machine. All methods
>> which are called in the state machine are implemented in the component
>> which loads the state machine. When I run the application the state
>> machine will be set to PROCESSING and MODULATING. sigCycleInport will
>> be triggered every 500 ms. It doesn’t matter if I only set one state
>> or if I delete the hierarchical state machines (Process and Modulate)
>> and directly calculate in the root state machine. The CPU load stays
>> much too high for that little example calculation. Otherwise the state machine does exactly what it should.
>
> If the state machine only runs twice a second, something really strange is going on as it's supposed to be able to do that 500x faster as well.
>
> Since the component is non-periodic, I would suppose that it is being re-triggered way too often.
>
> You can turn on debugging of your state machine with
>
> RTT::scripting::ScriptingService::shared_ptr ss = dynamic_pointer_cast<RTT::scripting::ScriptingService>(
> this->provides("scripting") );
> StateMachine::shared_ptr sm =ss->getStateMachine("rootFSM");
> sm->trace(true);
> sm = ss->getStateMachine("rootFSM.processFSM")
> sm->trace(true);
>
> In your configureHook(). Hope this clarifies what is going on...
>
> Peter
>
>>
>>
>>
>> Sandra
>>
>>
>>
>> Von: Peter Soetens [mailto:peter [..] ...]
>> Gesendet: Montag, 23. Juni 2014 12:36
>>
>>
>> An: Sandra Beyer
>> Cc: orocos-users
>> Betreff: Re: [Orocos-users] High CPU load when using orocos state
>> machines
>>
>>
>>
>> Hi Sandra,
>>
>>
>>
>> Please always show a short code example + orocos version, since this
>> eliminates us second guessing the scripting language you're using.
>>
>>
>>
>> The classic rtt state machines are designed to run efficiently at 1ms...
>> They were made to run synchronously with your realtime controller.
>>
>>
>>
>> There could be a regression in the event processing code which the
>> unit tests dont catch. So please provide an example.
>>
>>
>>
>> With respect to the rfsm vs classical fsm, both can be made equally
>> hard real-time, but it requires more careful setup/programming with rfsm.
>>
>>
>>
>> Peter
>>
>> Op maandag 23 juni 2014 heeft Sandra Beyer <sandra [dot] beyer [..] ...>
>> het volgende geschreven:
>>
>> Hi,
>>
>>
>>
>> I have a big problem with the CPU load, when using Orocos state
>> machines. My application consists of 3 threads. 2 of them run cyclic
>> (period: less than 1 ms). The third is a non periodic task (period 0),
>> which is managed over an Orocos hierarchical state machine. The state
>> machine is triggered over event ports, which will be set from the 2
>> periodic threads. The functionality of the state machine works fine. I
>> load, activate and start all state machines during configuration time
>> of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
>>
>> When I replace the reaction to the event ports via the Orocos state
>> machine with direct callback functions for each port the CPU load decreases to 5%.
>>
>> I don’t calculate much. So it’s completely strange and inadmissible
>> that the CPU load is so high when using the state machine. The only
>> thing, which could increase the CPU load, are the context switches between the threads.
>>
>>
>>
>> Does anyone have any idea why the state machines increase the CPU load
>> so much? Is an Orocos state machine really executed in the thread
>> context, where I load the state machine or will be created another
>> thread for the state machine? Are there any limits for the period of
>> Orocos threads or the usage of Orocos state machines? (Is less than 1
>> ms for more than one thread even working? Is an event reaction over
>> state machines working with a high event rate?) Do exist timing
>> analysis about the cost of Orocos thread and Orocos state machine usage?
>>
>>
>>
>>
>>
>> Thanks a lot for any help.
>>
>>
>>
>> Greetings
>>
>> Sandra
>>
>>
>>
>> --
>> Peter Soetens, Managing Director
>> +32 473 170 240
>> Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM
>> www.intermodalics.eu
>
>
>
> --
> Peter Soetens, Managing Director
> +32 473 170 240
> Intermodalics - Kapeldreef 60, 3001 Heverlee - BELGIUM www.intermodalics.eu
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

High CPU load when using orocos state machines

Hi Nicola,
I don’t have any while(true) statements in the state machine. I only call calculating methods which are implemented in the component, where I load the state machine, and write a new status to an output port. The only extra statement is trigger(), which I need for processing all incoming events (buffered event port). But without that trigger() the load is the same. So this should not effect anything.

One of the two periodic components sends an event every single cycle. Every 500 ms at the moment but we probably have to speed up more. (I’m not sure if Orocos can handle this). The other periodic component doesn’t send events on every single cycle.

Sandra

Von: Nicola Preda [mailto:nicola [dot] preda [..] ...]
Gesendet: Montag, 23. Juni 2014 09:46
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

Hi Sandra,

are you sending events at every cycle of the two periodic components? Have you got a "doo" function defined for one of the states of the fsm in which you have inserted a while(true) loop with a breaking condition but without using "yield()"?

Nicola

2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>>:
Hi,

I have a big problem with the CPU load, when using Orocos state machines. My application consists of 3 threads. 2 of them run cyclic (period: less than 1 ms). The third is a non periodic task (period 0), which is managed over an Orocos hierarchical state machine. The state machine is triggered over event ports, which will be set from the 2 periodic threads. The functionality of the state machine works fine. I load, activate and start all state machines during configuration time of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
When I replace the reaction to the event ports via the Orocos state machine with direct callback functions for each port the CPU load decreases to 5%.
I don’t calculate much. So it’s completely strange and inadmissible that the CPU load is so high when using the state machine. The only thing, which could increase the CPU load, are the context switches between the threads.

Does anyone have any idea why the state machines increase the CPU load so much? Is an Orocos state machine really executed in the thread context, where I load the state machine or will be created another thread for the state machine? Are there any limits for the period of Orocos threads or the usage of Orocos state machines? (Is less than 1 ms for more than one thread even working? Is an event reaction over state machines working with a high event rate?) Do exist timing analysis about the cost of Orocos thread and Orocos state machine usage?

Thanks a lot for any help.

Greetings
Sandra

--
Orocos-Users mailing list
Orocos-Users [..] ...<mailto:Orocos-Users [..] ...>
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

High CPU load when using orocos state machines

2014-06-23 10:09 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:

> Hi Nicola,
>
> I don’t have any while(true) statements in the state machine. I only call
> calculating methods which are implemented in the component, where I load
> the state machine, and write a new status to an output port. The only extra
> statement is trigger(), which I need for processing all incoming events
> (buffered event port). But without that trigger() the load is the same. So
> this should not effect anything.
>
>
>
> One of the two periodic components sends an event every single cycle.
> Every 500 ms at the moment but we probably have to speed up more. (I’m not
> sure if Orocos can handle this). The other periodic component doesn’t send
> events on every single cycle.
>

May the events sent by the component running at 500ms trigger a
self-transition for a certain state of the fsm?

Are you writing the events just once after they occur (for example at the
end of a method call) or are you writing them at every cycle (i.e. with a
write on a port in the updateHook)?

I suggest you to try to insert a rfsm.yield() call inside the doo function
(after a call to a method for example) of the state and see if the load of
the CPU changes.
rfsm.yield() hides a call to coroutine.yield() of Lua and, in simple terms,
it should prevent the Lua engine from keeping the CPU busy. If you are not
familiar with Lua coroutines you can think at them like at something
similar to a multithreading system (even if they are not the same indeed).

Nicola

>
>
> Sandra
>
>
>
>
>
> *Von:* Nicola Preda [mailto:nicola [dot] preda [..] ...]
> *Gesendet:* Montag, 23. Juni 2014 09:46
> *An:* Sandra Beyer
> *Cc:* orocos-users
> *Betreff:* Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
> Hi Sandra,
>
>
>
> are you sending events at every cycle of the two periodic components? Have
> you got a "doo" function defined for one of the states of the fsm in which
> you have inserted a while(true) loop with a breaking condition but without
> using "yield()"?
>
>
>
> Nicola
>
>
>
> 2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
>
> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state machines.
> My application consists of 3 threads. 2 of them run cyclic (period: less
> than 1 ms). The third is a non periodic task (period 0), which is managed
> over an Orocos hierarchical state machine. The state machine is triggered
> over event ports, which will be set from the 2 periodic threads. The
> functionality of the state machine works fine. I load, activate and start
> all state machines during configuration time of the thread. But when I
> check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps
> between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state
> machine with direct callback functions for each port the CPU load decreases
> to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible that
> the CPU load is so high when using the state machine. The only thing, which
> could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load so
> much? Is an Orocos state machine really executed in the thread context,
> where I load the state machine or will be created another thread for the
> state machine? Are there any limits for the period of Orocos threads or the
> usage of Orocos state machines? (Is less than 1 ms for more than one thread
> even working? Is an event reaction over state machines working with a high
> event rate?) Do exist timing analysis about the cost of Orocos thread and
> Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>
>

High CPU load when using orocos state machines

Most of the 500 ms event triggers a self-transition. Is that a problem? The events are written in the updateHook() of the 500ms component. It seems that it doesn’t make any difference if they are written in the middle or in the end of the updateHook().

I don’t use the Lua rfsm. I use the the state machine syntax which Orocos provides for its own. (*.osd files). But I tried yield anyway. But it doesn’t make any difference. Is it better to use Lua if you have high periodical components?

Sandra

Von: Nicola Preda [mailto:nicola [dot] preda [..] ...]
Gesendet: Montag, 23. Juni 2014 10:59
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

2014-06-23 10:09 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>>:
Hi Nicola,
I don’t have any while(true) statements in the state machine. I only call calculating methods which are implemented in the component, where I load the state machine, and write a new status to an output port. The only extra statement is trigger(), which I need for processing all incoming events (buffered event port). But without that trigger() the load is the same. So this should not effect anything.

One of the two periodic components sends an event every single cycle. Every 500 ms at the moment but we probably have to speed up more. (I’m not sure if Orocos can handle this). The other periodic component doesn’t send events on every single cycle.

May the events sent by the component running at 500ms trigger a self-transition for a certain state of the fsm?

Are you writing the events just once after they occur (for example at the end of a method call) or are you writing them at every cycle (i.e. with a write on a port in the updateHook)?

I suggest you to try to insert a rfsm.yield() call inside the doo function (after a call to a method for example) of the state and see if the load of the CPU changes.
rfsm.yield() hides a call to coroutine.yield() of Lua and, in simple terms, it should prevent the Lua engine from keeping the CPU busy. If you are not familiar with Lua coroutines you can think at them like at something similar to a multithreading system (even if they are not the same indeed).

Nicola

Sandra

Von: Nicola Preda [mailto:nicola [dot] preda [..] ...<mailto:nicola [dot] preda [..] ...>]
Gesendet: Montag, 23. Juni 2014 09:46
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

Hi Sandra,

are you sending events at every cycle of the two periodic components? Have you got a "doo" function defined for one of the states of the fsm in which you have inserted a while(true) loop with a breaking condition but without using "yield()"?

Nicola

2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>>:
Hi,

I have a big problem with the CPU load, when using Orocos state machines. My application consists of 3 threads. 2 of them run cyclic (period: less than 1 ms). The third is a non periodic task (period 0), which is managed over an Orocos hierarchical state machine. The state machine is triggered over event ports, which will be set from the 2 periodic threads. The functionality of the state machine works fine. I load, activate and start all state machines during configuration time of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
When I replace the reaction to the event ports via the Orocos state machine with direct callback functions for each port the CPU load decreases to 5%.
I don’t calculate much. So it’s completely strange and inadmissible that the CPU load is so high when using the state machine. The only thing, which could increase the CPU load, are the context switches between the threads.

Does anyone have any idea why the state machines increase the CPU load so much? Is an Orocos state machine really executed in the thread context, where I load the state machine or will be created another thread for the state machine? Are there any limits for the period of Orocos threads or the usage of Orocos state machines? (Is less than 1 ms for more than one thread even working? Is an event reaction over state machines working with a high event rate?) Do exist timing analysis about the cost of Orocos thread and Orocos state machine usage?

Thanks a lot for any help.

Greetings
Sandra

--
Orocos-Users mailing list
Orocos-Users [..] ...<mailto:Orocos-Users [..] ...>
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

High CPU load when using orocos state machines

2014-06-23 11:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:

> Most of the 500 ms event triggers a self-transition. Is that a problem?
> The events are written in the updateHook() of the 500ms component. It seems
> that it doesn’t make any difference if they are written in the middle or in
> the end of the updateHook().
>

Are you sure that the update of the state terminates before it is called
again because of the next self-transition?

>
>
> I don’t use the Lua rfsm. I use the the state machine syntax which Orocos
> provides for its own. (*.osd files). But I tried yield anyway. But it
> doesn’t make any difference. Is it better to use Lua if you have high
> periodical components?
>

Sorry, I was under the conviction that you were using rFSM. Honestly I have
always used rFSM so I can't provide you any feedback about Orocos built-in
fsm and about which could be the "best" choice for your requirements.. I
can only say that from my experience rFSM is a robust tool and that it
nicely integrates with the system.

Nicola

>
> Sandra
>
>
>
> *Von:* Nicola Preda [mailto:nicola [dot] preda [..] ...]
> *Gesendet:* Montag, 23. Juni 2014 10:59
> *An:* Sandra Beyer
>
> *Cc:* orocos-users
> *Betreff:* Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
>
>
>
>
> 2014-06-23 10:09 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
>
> Hi Nicola,
>
> I don’t have any while(true) statements in the state machine. I only call
> calculating methods which are implemented in the component, where I load
> the state machine, and write a new status to an output port. The only extra
> statement is trigger(), which I need for processing all incoming events
> (buffered event port). But without that trigger() the load is the same. So
> this should not effect anything.
>
>
>
> One of the two periodic components sends an event every single cycle.
> Every 500 ms at the moment but we probably have to speed up more. (I’m not
> sure if Orocos can handle this). The other periodic component doesn’t send
> events on every single cycle.
>
>
>
> May the events sent by the component running at 500ms trigger a
> self-transition for a certain state of the fsm?
>
>
>
> Are you writing the events just once after they occur (for example at the
> end of a method call) or are you writing them at every cycle (i.e. with a
> write on a port in the updateHook)?
>
>
>
> I suggest you to try to insert a rfsm.yield() call inside the doo function
> (after a call to a method for example) of the state and see if the load of
> the CPU changes.
>
> rfsm.yield() hides a call to coroutine.yield() of Lua and, in simple
> terms, it should prevent the Lua engine from keeping the CPU busy. If you
> are not familiar with Lua coroutines you can think at them like at
> something similar to a multithreading system (even if they are not the same
> indeed).
>
>
>
> Nicola
>
>
>
>
>
> Sandra
>
>
>
>
>
> *Von:* Nicola Preda [mailto:nicola [dot] preda [..] ...]
> *Gesendet:* Montag, 23. Juni 2014 09:46
> *An:* Sandra Beyer
> *Cc:* orocos-users
> *Betreff:* Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
> Hi Sandra,
>
>
>
> are you sending events at every cycle of the two periodic components? Have
> you got a "doo" function defined for one of the states of the fsm in which
> you have inserted a while(true) loop with a breaking condition but without
> using "yield()"?
>
>
>
> Nicola
>
>
>
> 2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
>
> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state machines.
> My application consists of 3 threads. 2 of them run cyclic (period: less
> than 1 ms). The third is a non periodic task (period 0), which is managed
> over an Orocos hierarchical state machine. The state machine is triggered
> over event ports, which will be set from the 2 periodic threads. The
> functionality of the state machine works fine. I load, activate and start
> all state machines during configuration time of the thread. But when I
> check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps
> between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state
> machine with direct callback functions for each port the CPU load decreases
> to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible that
> the CPU load is so high when using the state machine. The only thing, which
> could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load so
> much? Is an Orocos state machine really executed in the thread context,
> where I load the state machine or will be created another thread for the
> state machine? Are there any limits for the period of Orocos threads or the
> usage of Orocos state machines? (Is less than 1 ms for more than one thread
> even working? Is an event reaction over state machines working with a high
> event rate?) Do exist timing analysis about the cost of Orocos thread and
> Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>
>
>
>

High CPU load when using orocos state machines

Yes, all self-transitions terminated before the next cycle.
After some researches we decided to not use rFSM cause we need to be hard real time safe ( http://www.orocos.org/forum/orocos/orocos-users/orocos-script-vs-lua-script ).
Thanks a lot anyway.
Sandra
Von: Nicola Preda [mailto:nicola [dot] preda [..] ...]
Gesendet: Montag, 23. Juni 2014 11:41
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

2014-06-23 11:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>>:
Most of the 500 ms event triggers a self-transition. Is that a problem? The events are written in the updateHook() of the 500ms component. It seems that it doesn’t make any difference if they are written in the middle or in the end of the updateHook().

Are you sure that the update of the state terminates before it is called again because of the next self-transition?

I don’t use the Lua rfsm. I use the the state machine syntax which Orocos provides for its own. (*.osd files). But I tried yield anyway. But it doesn’t make any difference. Is it better to use Lua if you have high periodical components?

Sorry, I was under the conviction that you were using rFSM. Honestly I have always used rFSM so I can't provide you any feedback about Orocos built-in fsm and about which could be the "best" choice for your requirements.. I can only say that from my experience rFSM is a robust tool and that it nicely integrates with the system.

Nicola

Sandra

Von: Nicola Preda [mailto:nicola [dot] preda [..] ...<mailto:nicola [dot] preda [..] ...>]
Gesendet: Montag, 23. Juni 2014 10:59
An: Sandra Beyer

Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

2014-06-23 10:09 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>>:
Hi Nicola,
I don’t have any while(true) statements in the state machine. I only call calculating methods which are implemented in the component, where I load the state machine, and write a new status to an output port. The only extra statement is trigger(), which I need for processing all incoming events (buffered event port). But without that trigger() the load is the same. So this should not effect anything.

One of the two periodic components sends an event every single cycle. Every 500 ms at the moment but we probably have to speed up more. (I’m not sure if Orocos can handle this). The other periodic component doesn’t send events on every single cycle.

May the events sent by the component running at 500ms trigger a self-transition for a certain state of the fsm?

Are you writing the events just once after they occur (for example at the end of a method call) or are you writing them at every cycle (i.e. with a write on a port in the updateHook)?

I suggest you to try to insert a rfsm.yield() call inside the doo function (after a call to a method for example) of the state and see if the load of the CPU changes.
rfsm.yield() hides a call to coroutine.yield() of Lua and, in simple terms, it should prevent the Lua engine from keeping the CPU busy. If you are not familiar with Lua coroutines you can think at them like at something similar to a multithreading system (even if they are not the same indeed).

Nicola

Sandra

Von: Nicola Preda [mailto:nicola [dot] preda [..] ...<mailto:nicola [dot] preda [..] ...>]
Gesendet: Montag, 23. Juni 2014 09:46
An: Sandra Beyer
Cc: orocos-users
Betreff: Re: [Orocos-users] High CPU load when using orocos state machines

Hi Sandra,

are you sending events at every cycle of the two periodic components? Have you got a "doo" function defined for one of the states of the fsm in which you have inserted a while(true) loop with a breaking condition but without using "yield()"?

Nicola

2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...sandra [dot] beyer [..] ...>>:
Hi,

I have a big problem with the CPU load, when using Orocos state machines. My application consists of 3 threads. 2 of them run cyclic (period: less than 1 ms). The third is a non periodic task (period 0), which is managed over an Orocos hierarchical state machine. The state machine is triggered over event ports, which will be set from the 2 periodic threads. The functionality of the state machine works fine. I load, activate and start all state machines during configuration time of the thread. But when I check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps between both CPUs.
When I replace the reaction to the event ports via the Orocos state machine with direct callback functions for each port the CPU load decreases to 5%.
I don’t calculate much. So it’s completely strange and inadmissible that the CPU load is so high when using the state machine. The only thing, which could increase the CPU load, are the context switches between the threads.

Does anyone have any idea why the state machines increase the CPU load so much? Is an Orocos state machine really executed in the thread context, where I load the state machine or will be created another thread for the state machine? Are there any limits for the period of Orocos threads or the usage of Orocos state machines? (Is less than 1 ms for more than one thread even working? Is an event reaction over state machines working with a high event rate?) Do exist timing analysis about the cost of Orocos thread and Orocos state machine usage?

Thanks a lot for any help.

Greetings
Sandra

--
Orocos-Users mailing list
Orocos-Users [..] ...<mailto:Orocos-Users [..] ...>
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users

High CPU load when using orocos state machines

I think that here it has been stated the opposite:
https://lwn.net/images/conf/rtlws-2011/proc/Klotzbuecher.pdf

You are welcome.
Nicola

2014-06-23 11:50 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:

> Yes, all self-transitions terminated before the next cycle.
>
> After some researches we decided to not use rFSM cause we need to be hard
> real time safe (
> http://www.orocos.org/forum/orocos/orocos-users/orocos-script-vs-lua-script
> ).
>
> Thanks a lot anyway.
>
> Sandra
>
> *Von:* Nicola Preda [mailto:nicola [dot] preda [..] ...]
> *Gesendet:* Montag, 23. Juni 2014 11:41
>
> *An:* Sandra Beyer
> *Cc:* orocos-users
> *Betreff:* Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
>
>
>
>
> 2014-06-23 11:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
>
> Most of the 500 ms event triggers a self-transition. Is that a problem?
> The events are written in the updateHook() of the 500ms component. It seems
> that it doesn’t make any difference if they are written in the middle or in
> the end of the updateHook().
>
>
>
> Are you sure that the update of the state terminates before it is called
> again because of the next self-transition?
>
>
>
>
>
> I don’t use the Lua rfsm. I use the the state machine syntax which Orocos
> provides for its own. (*.osd files). But I tried yield anyway. But it
> doesn’t make any difference. Is it better to use Lua if you have high
> periodical components?
>
>
>
> Sorry, I was under the conviction that you were using rFSM. Honestly I
> have always used rFSM so I can't provide you any feedback about Orocos
> built-in fsm and about which could be the "best" choice for your
> requirements.. I can only say that from my experience rFSM is a robust tool
> and that it nicely integrates with the system.
>
>
>
> Nicola
>
>
>
>
>
> Sandra
>
>
>
> *Von:* Nicola Preda [mailto:nicola [dot] preda [..] ...]
> *Gesendet:* Montag, 23. Juni 2014 10:59
> *An:* Sandra Beyer
>
>
> *Cc:* orocos-users
> *Betreff:* Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
>
>
>
>
> 2014-06-23 10:09 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
>
> Hi Nicola,
>
> I don’t have any while(true) statements in the state machine. I only call
> calculating methods which are implemented in the component, where I load
> the state machine, and write a new status to an output port. The only extra
> statement is trigger(), which I need for processing all incoming events
> (buffered event port). But without that trigger() the load is the same. So
> this should not effect anything.
>
>
>
> One of the two periodic components sends an event every single cycle.
> Every 500 ms at the moment but we probably have to speed up more. (I’m not
> sure if Orocos can handle this). The other periodic component doesn’t send
> events on every single cycle.
>
>
>
> May the events sent by the component running at 500ms trigger a
> self-transition for a certain state of the fsm?
>
>
>
> Are you writing the events just once after they occur (for example at the
> end of a method call) or are you writing them at every cycle (i.e. with a
> write on a port in the updateHook)?
>
>
>
> I suggest you to try to insert a rfsm.yield() call inside the doo function
> (after a call to a method for example) of the state and see if the load of
> the CPU changes.
>
> rfsm.yield() hides a call to coroutine.yield() of Lua and, in simple
> terms, it should prevent the Lua engine from keeping the CPU busy. If you
> are not familiar with Lua coroutines you can think at them like at
> something similar to a multithreading system (even if they are not the same
> indeed).
>
>
>
> Nicola
>
>
>
>
>
> Sandra
>
>
>
>
>
> *Von:* Nicola Preda [mailto:nicola [dot] preda [..] ...]
> *Gesendet:* Montag, 23. Juni 2014 09:46
> *An:* Sandra Beyer
> *Cc:* orocos-users
> *Betreff:* Re: [Orocos-users] High CPU load when using orocos state
> machines
>
>
>
> Hi Sandra,
>
>
>
> are you sending events at every cycle of the two periodic components? Have
> you got a "doo" function defined for one of the states of the fsm in which
> you have inserted a while(true) loop with a breaking condition but without
> using "yield()"?
>
>
>
> Nicola
>
>
>
> 2014-06-23 9:15 GMT+02:00 Sandra Beyer <sandra [dot] beyer [..] ...>:
>
> Hi,
>
>
>
> I have a big problem with the CPU load, when using Orocos state machines.
> My application consists of 3 threads. 2 of them run cyclic (period: less
> than 1 ms). The third is a non periodic task (period 0), which is managed
> over an Orocos hierarchical state machine. The state machine is triggered
> over event ports, which will be set from the 2 periodic threads. The
> functionality of the state machine works fine. I load, activate and start
> all state machines during configuration time of the thread. But when I
> check the CPU load of my PowerPC (2 CPUs) it’s nearly 90%. The load jumps
> between both CPUs.
>
> When I replace the reaction to the event ports via the Orocos state
> machine with direct callback functions for each port the CPU load decreases
> to 5%.
>
> I don’t calculate much. So it’s completely strange and inadmissible that
> the CPU load is so high when using the state machine. The only thing, which
> could increase the CPU load, are the context switches between the threads.
>
>
>
> Does anyone have any idea why the state machines increase the CPU load so
> much? Is an Orocos state machine really executed in the thread context,
> where I load the state machine or will be created another thread for the
> state machine? Are there any limits for the period of Orocos threads or the
> usage of Orocos state machines? (Is less than 1 ms for more than one thread
> even working? Is an event reaction over state machines working with a high
> event rate?) Do exist timing analysis about the cost of Orocos thread and
> Orocos state machine usage?
>
>
>
>
>
> Thanks a lot for any help.
>
>
>
> Greetings
>
> Sandra
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>
>
>
>
>
>