Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » CPC Timer Handler - linux thread performance
CPC Timer Handler - linux thread performance [message #1768916] Tue, 25 July 2017 01:00 Go to next message
Todd Cunningham is currently offline Todd CunninghamFriend
Messages: 2
Registered: July 2017
Junior Member
Hello,

I am currently doing some performance analysis on a Forte implementation in an embedded environment and have found that the CPCTimerHandler thread seems to be a performance hog even when no forte resources are currently running. Is this an expected behaviour? It is my understanding that the thread is used to notify timer function blocks which should not be required when no resources are running.

Has anyone had similar findings? I have done a bit of hacking around with the enable/disableHandler functions in an attempt to mitigate unnecessary cpu usage by this timer thread with some success but am concerned these changes may effect other interactions that I am not familiar with.

Specifically, enabling the TimerHandler from the CEventchainExecutionThread constructor if a resource will be loaded and and disabling the timer from the createDev function in posix/main.cpp.

Any input on problems with my understanding or consequences with the suggested workaround are greatly appreciated. Has anyone had luck improving the efficiency of the posix CPCTimerHandler::run function?
Re: CPC Timer Handler - linux thread performance [message #1769009 is a reply to message #1768916] Tue, 25 July 2017 15:41 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 617
Registered: January 2014
Senior Member
hi,

thanks for pointing this out. It should definitely not take away the full performance an the intention is that the thread is sleeping most of the time and only woken up with x ticks per second. For posix targets we are using nanosleep for this task. In addition to informing timed fbs the timer handler is also in charge of maintainig a platform independent version of time. Which can be used in algorithms to perform some low precision measurements.

I had a quick look at the code and I noticed that one performance issue is the cirtical region which is entered in 89 of timerha.cpp. A solution that could improve the situation is to change line 88 to: "if (0 != m_pstTimedFBList){"
Would you mind giving it a try and let us know if it brings some improvements?
Re: CPC Timer Handler - linux thread performance [message #1769038 is a reply to message #1769009] Wed, 26 July 2017 05:07 Go to previous messageGo to next message
Todd Cunningham is currently offline Todd CunninghamFriend
Messages: 2
Registered: July 2017
Junior Member
Hi Alois,

Thanks for the suggestion and other information. I tinkered it a bit more and ended up finding some decent improvement by cutting our ticks per second to 100 rather than 1000 as 10ms resolution should be fine for our purposes and decreased the usage by about 75% (~2% CPU to ~0.4%). Your suggestion also offered some performance improvement (seems to be about 5~10%) when no resources are running. Performance when >0 resources are running is roughly equal, which if I understand correctly is expected.

To build off what I mentioned before, though I'm not sure it would be very straightforward to implement into the current architechture, from a conceptual standpoint I think it makes sense to only run the timer when there are resources using it.

I believe these updates will work for my needs at the moment. Thanks again!
Re: CPC Timer Handler - linux thread performance [message #1769076 is a reply to message #1769038] Wed, 26 July 2017 10:03 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 617
Registered: January 2014
Senior Member
Thanks for testing. Given your feedback I'll added a bug report [1] so that the line will make it into the next FORTE release.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=520202
Previous Topic:Polysun 4diac plugin controller
Next Topic:OPC_UA Subscribe FB Var Initialization
Goto Forum:
  


Current Time: Sat Aug 18 08:54:39 GMT 2018

Powered by FUDForum. Page generated in 0.02177 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top