Jump to content



Photo
- - - - -

DOFLinx 10.03: high CPU usage with DEBUG_TCP_PORT client and possible worker leak on reconnect


  • Please log in to reply
7 replies to this topic

#1 Pyrrvs

Pyrrvs

    Neophyte

  • Members
  • Pip
  • 3 posts

  • Flag: ---------

  • Favorite Pinball: Ghost Busters

Posted 02 October 2026 - 11:33 AM

Hi DDH69,

I don't know if this is the right way to report a bug, please let me know if I should report this differently or elsewhere.

 

I use DOFLinx 10.03 with Pinball FX and Pinball FX Midnight, with DEBUG_TCP_PORT=47831 and a TCP client connected to 127.0.0.1.

With one TCP client connected, I observed approximately 125 seconds of cumulative process CPU time over 96 seconds of wall time. After restarting DOFLinx without a TCP client, CPU usage was substantially lower. This is an indicative observation, not yet a controlled benchmark.

 

Read-only inspection of the installed executable suggests that:

  • The client worker loops without waiting when the outgoing queue is empty.
  • The worker continues looping after a write failure or disconnection.
  • Reconnections may therefore accumulate active workers.
  • The two-millisecond delay runs only after sending a message

I collected logs and CPU measurements for four scenarios, each lasting approximately 30 seconds:

  • After a fresh start, without a TCP client: 0.84 seconds of CPU time.
  • With one TCP client connected, receiving no data: 31.02 seconds.
  • After disconnecting that client: 31.08 seconds, with the server-side socket still in CLOSE_WAIT.
  • After restarting DOFLinx again, without a client: 0.72 seconds.

The configuration remained unchanged throughout, with DEBUG=2 and DEBUG_TCP_PORT=47831. No Pinball game was running during these measurements.

I would be happy to help reproduce the issue, collect CPU and resource measurements, and test a candidate fix. If you’re comfortable sharing the relevant source, I could also help develop and test a patch.

 

Thank you for your work on DOFLinx.

 

 



#2 DDH69

DDH69

    Pinball Wizard

  • Platinum Supporter
  • 3,636 posts
  • Location:DOFLinx HQ, Adelaide

  • Flag: Australia

  • Favorite Pinball: Monster Bash

Posted 04 October 2026 - 11:00 AM

Thank you.  Information received, appreciated and understood.  I added this for me and made it available to all.  Over time it has not been used much, so the bug is probably from the original implementation.  Let me look into it.  I will hopefully make some improvements and report back, probably for some testing assitance.


DOFLinx
Contributions for equipment to help with ongoing DOFLinx development can be made here

#3 DDH69

DDH69

    Pinball Wizard

  • Platinum Supporter
  • 3,636 posts
  • Location:DOFLinx HQ, Adelaide

  • Flag: Australia

  • Favorite Pinball: Monster Bash

Posted 04 October 2026 - 11:10 AM

Just looking now.  It seems I have not paused the thread after sending the message via TCP.  I've added some code to do so and will test shortly.

 

Are you using DOFLinx Windows or Linux?


Edited by DDH69, 04 October 2026 - 11:11 AM.

DOFLinx
Contributions for equipment to help with ongoing DOFLinx development can be made here

#4 Pyrrvs

Pyrrvs

    Neophyte

  • Members
  • Pip
  • 3 posts

  • Flag: ---------

  • Favorite Pinball: Ghost Busters

Posted 04 October 2026 - 02:00 PM

I am using DOFLinx on Windows! Thanks for the quick reply and troubleshoot.

Let me know if I can help with the testing part.



#5 DDH69

DDH69

    Pinball Wizard

  • Platinum Supporter
  • 3,636 posts
  • Location:DOFLinx HQ, Adelaide

  • Flag: Australia

  • Favorite Pinball: Monster Bash

Posted 04 October 2026 - 11:43 PM

Attached is a beta with I believe a fix.  Please have a test and let me know your results.

Attached Files


DOFLinx
Contributions for equipment to help with ongoing DOFLinx development can be made here

#6 DDH69

DDH69

    Pinball Wizard

  • Platinum Supporter
  • 3,636 posts
  • Location:DOFLinx HQ, Adelaide

  • Flag: Australia

  • Favorite Pinball: Monster Bash

Posted 05 October 2026 - 06:23 AM

Here is a second beta.  In further testing I found that a message could be missed under extreme load.

Attached Files


DOFLinx
Contributions for equipment to help with ongoing DOFLinx development can be made here

#7 Pyrrvs

Pyrrvs

    Neophyte

  • Members
  • Pip
  • 3 posts

  • Flag: ---------

  • Favorite Pinball: Ghost Busters

Posted 06 October 2026 - 07:08 PM

Thank you for the beta! I tested beta 2 and the idle CPU issue looks resolved! I measured about 0.28 seconds of CPU time over 30 seconds with one idle TCP client, versus 0.25 seconds without a client.

 

I made a few more tests and I think we still have a problem with client cleanup. This is less of an issue IMO as I don't intend having tons of client connecting/disconnecting but I thought I would share that with you: I simulated 100 reconnections that approximately added 100 threads and 600 handles, which did not return to baseline during recovery (I waited a while to be sure). The worker should probably detect disconnection even while waiting for messages, exit on disconnect or write failure, and dispose its stream/socket?

 

Thanks again for looking into this and resolving this issue so quickly.



#8 DDH69

DDH69

    Pinball Wizard

  • Platinum Supporter
  • 3,636 posts
  • Location:DOFLinx HQ, Adelaide

  • Flag: Australia

  • Favorite Pinball: Monster Bash

Posted 07 October 2026 - 05:02 AM

Thanks for the feedback.  I had not tested that. The design is really about connecting and staying connected while logging, as you say, not on / off repeatably.  However, it should work correctly :-)

 

I've added some clean-up routine when a TCP connection is no longer active.  This will not clean-up at disconnect rather at first failure, so technically the next attempted send after the disconnect.

 

Let me know how you go with this.

Attached Files


DOFLinx
Contributions for equipment to help with ongoing DOFLinx development can be made here