Hello folks, new XOJO pro user here.
Some Background
I have a UDP based application that has a roll-your-own congestion window, selective repeat, fast recovery, piggybacking, the works. To clarify, this application requires UDP to perform NAT traversal so the TCP socket was never an option, and the XOJO UDP socket performs quite well. I have been working on Xojo 3.1 under windows 7 and so far have not had any significant issues until now. Unfortunately, this application is to be distributed to students worldwide, particularly to a low-income (third-world, i.e. freeware) audience who will not be using windows as an operating system (if they have any at all) and thus will require to boot a DVD live CD of a Linux distro (TBD) to use this application on whatever serviceable hardware they can assemble to be able to boot the live CD (Their problem). To be sure, implementing NAT traversal and a customized ARQ/hints for high RTT VSAT and long haul 802.11x operation took less than a day, so my hats off to the simplicity of the Xojo language.
Now on to the problem:
Under windows 7, I have been using a thread to call the UDP socket’s poll method and continuously check the socket’s PacketsAvailable property to see if anything has arrived. When packets arrive, the thread executes a loop to read the socket until the PacketsAvailable property is zero. All the activity for the congestion control and ARQ are handled in the thread and the socket’s dataAvailable event is unused. Under windows 7 and 8 the compiled applications perform flawlessly, but when I compiled the application for the linux target, the applications use 100 percent of the CPU time even with no activity whatsoever. After pulling my hair out for a few days, I discovered that even idle threads consume 100% CPU under Linux (please see case 370) and this has been a known issue since 2007. To compound issues further, I have discovered this is also occurring under our single CPU Go Daddy virtual private server (running windows server 2008 r2, sp1) that is used to facilitate the students to connect to each other. I understand that Windows Server 2008 would in all probability not be supported, and a Linux replacement for the server could easily be used if it worked. In some desperation, I tried to use timers in place of threads which worked but delivered a pathetically slow 800kb over the wired lan. So I also tried aggregating multiple UDP sockets on different ports to make up for the tiny resolution that the timer provided to poll and read (and thus the limited throughput) This works for the low bandwidth text portion but will be useless to transfer the video based training material and is a bona fide hack-job to say the least. Each connection would have to use upwards of 10 concurrent UDP sockets to even approach the performance that is easily delivered under the functioning Windows 7 build, and adding even more uncertainty about how I will go about any realistic binary file transfer (critical to deliver the prerecorded video content) if I am forced to read the binary stream in a unthreaded loop, while operating the time sensitive congestion window in the same executable.
I have tried using the sleep, this does nothing to alleviate the usage under Linux; I have tried building simple ad-hoc thread tests using every distro and every computer I could lay my hands on. Its Xojos threading under Linux, and I am not the only one to have discovered this issue, just look at the cases for linux and threads. To be clear, this application works correctly under both windows 7, 8 and even my macbook. Please take note that this will even cause thermal issues on Linux computers with prolonged usage, as all my test laptops fans operated in high very high RPM regimes during prolonged execution.
What I have tried:
-
Raw thread class instanced and incrementing a simple integer counter, with a sleep(10) added in the loop, this works perfectly and idles at an amount that hardly registers. Under Linux, this consumes 100 percent on every system and distro I have.
-
Timers: delivers about 2% of the performance and will do nothing to address simultaneous binary stream reading and congestion window operations.
-
Running the thread without looping it, letting it run to completion and using a timer to instance a new thread when it is not running. (This method is useless as it still uses 30 percent of CPU time on each loop and is causing major interference with the ack clocking as it requires a very high sleep() interval to not consume the entire processor.
-
Linux Mint, Ubuntu, CentOS, all 32 bit distros all exhibit the exact same issue. Honestly, I could use ANY distro that worked so I am NOT picky.
-
Profanity and prayer, neither have helped, and I am slowly coming to terms with having to rewrite the entire application again, in another language.
My questions are this:
-
Has anybody found any distro (any at all) that threads work correctly under?
-
Does anybody know of a Real Studio IDE build that I could be using that threading functions correctly under Linux?
-
Has anybody achieved useful binary file transfer performance with the sockets (UDP or TCP) under LINUX WITHOUT using threading of any kind?
-
Does anybody have any possible workarounds they could suggest?
Im greatly appreciative of any suggestions that you might have, thank you very much!