c++ace

CPU issue running ACE library version 7.0.6 in Linux Ubuntu


Moving to Linux Ubuntu from windows, ACE library version **7.0.6 **in Linux Ubuntu.

Server socket listening to traffic:

  1. received socket connection and connection is accepted

  2. Application is receiving excessive handle_output() where our app inherits from ACE_Event_Handler in Event_Handler.cpp . The excessive calls to output_handler from ACE causes a CPU issue.

  3. we ran the profiler we see a lot of calls to ACE_handle_Set::Reset() (125,000 calls) and ACE_Event_Handler::set_max(87,000 calls), not sure ?

My question is there a way to stop callbacks from ACE handle_output() and what is triggering ACE_handle_Set::Reset() ?

running the application in Linux VM or ec2 have the same issue CPU up to 100%


Solution

  • This is because of a difference in the way the underlying Reactor implementations on Windows and Linux behave. Complete details are in "The ACE Programmer's Guide" section 7.2.3. Windows WFMO is "edge triggered" so handle_output is only triggered when the socket goes from not-writeable to writeable. Linux is "level-triggered" so handle_output will continue to be called back as long as it returns 0 and the socket remains writeable as it almost always is.

    One way to handle this is to only register for output when the app has something to write, has attempted the write, and it could not complete. This is portable behavior across both platforms. The book has a more complete example and explanation.