Cleric-K / vJoySerialFeeder

Feed Virtual Joystick driver with data from a serial port
GNU General Public License v3.0
252 stars 55 forks source link

High CPU usage #23

Closed Wuerfel21 closed 5 years ago

Wuerfel21 commented 5 years ago

I'm using the feeder with an IBUS source I made myself (basically the ibus arduino code ported to SPIN). It sends 6 channels at almost 1000 Hz (yes I know, that's a little bit overkill). When connected, vJoySerialFeeder uses 4 to 5% CPU (my PC has an AMD Ryzen 1600X hexacore CPU with hyperthreading (=12 logical CPUs), so that actually comes out to 60% of one thread(at 3.9 GHz!)). Some optimization should be done to reduce this.

Cleric-K commented 5 years ago

Hi, I'm aware of situations like this. Unfortunately the CPU consumption happens inside the driver layer of the serial device. So there's not much I can do.

I've had even worse experiences with specific types of UART converters which have even higher than that CPU usage. It all depends on how well the Windows driver itself is written.

You can confirm if this is the case if you try to open the COM port with any other program (for example PuTTY). You should see similar CPU usage as vjsf.

Please make a test like that if possible and tell me how it went.

Wuerfel21 commented 5 years ago

Opening the COM port in the terminal that comes with Propeller Tool results in 1 to 2% CPU usage (more than I'd expect, but less than vjsf).

Cleric-K commented 5 years ago

You can try run vjsf with the dummy protocol (instead of IBUS). This basically eliminates the serial part so it gives some idea how much cpu vjsf itself consumes.

Updating the virtual joystick also add small overhead. You can try set the virtual joystick driver to none to see if this affects cpu.

The most simple way would be simply to reduce the frame rate. What is the motivation for using such a high frame rate? Most of these frames are not even possible to be detected by the game engine, since it runs at much lower than 1000fps. They go by unnoticed and simply waste resources.

Wuerfel21 commented 5 years ago

I know 1000 Hz is a little overkill (altough I play many games at over 100Hz, so I guess it's not even an entire order of magnitude above, lol) . Just thought the high usage was odd. But it doesn't seem to cause any actual problems. And yes, the dummy protocol reduces the CPU usage.