Sunday, February 14, 2016

USB Polling speed

I was just doing a little reading about how to reduce input lag in MAME.

Hopefully I already don't have much, since I'm using Shmupmame, which is designed specifically to reduce input lag.

But I came across an interesting little post...

http://forums.shoryuken.com/discussion/162624/mame-emulator-input-lag-test

In it, he says:

"I've also noticed that Win7 USB poll rates are 125hz aka 8ms by default; granted there are a few hacks to force the 1000hz (1ms) rate"

What!!! You mean to say that it is possible to shave 7ms off the input by doing some hacking?

7ms difference might not sound like much, but I will say with absolute certainty, when I was working on tweaking the latency on my e-drums, I could DEFINITELY tell the difference between 10ms latency and 5ms latency. I tried to get it as low as possible and it just "felt" better to play drums that way!

So who says that it isn't the same for game inputs? What if our brains can notice the subtle difference of having a faster input, and therefore play better?

I think it's definitely worth researching anyway...   As the famous Tim Allen would say...


So, in my initial research it appears that most people are using this "USB overclocking" for their mice, to get additional precision on high DPI gaming mice. Makes sense. 

But I think it's worth researching for arcade gaming as well.

Unfortunately, I have already read several accounts of people damaging or frying USB ports on their motherboard by "overclocking" them to 1000hz. 

So is it worth the risk? I'm not sure....   There's the saying "Tis better to have loved and lost than to never have loved at all".. But I'm not sure if it also applies to "Tis better to have attempted to overclock your USB port and accidentally fry your motherboard than to never have attempted to overclock your USB port at all".... LOL

From what I understand:

125hz (default) = 8ms
250hz = 4ms
500hz = 2ms
1000hz = 1ms

If 1000hz is the one that is most likely to damage the board, then maybe I'll just try 500hz and still shave off 6ms latency!

So my next question is: Will this affect all USB ports on my system or just a single port? I don't really think I need to overclock my USB sound interface.

I found this statement:

The HIDUSBF method only affects the specific device you apply the polling rate change to. There was an older method for Windows XP and earlier that patched the system usb port driver and affected all devices

And indeed, the HIDUSBF method seems to be the best, at least on Windows. I've found several sources:
 
http://www.mikemartin.co/system_guides/hardware/mouse/polling_rate  - Gives some general info about it including another reminder that 1000hz may fry your motherboard

and

http://www.ngohq.com/news/15043-how-to-increase-usb-sample-rate-in-windows-vista-7-a.html - Includes the download.

Now I hope I can make this work with keyboard and gamepad and not just mice!

Regarding safety, here is probably the most useful page I have found:

http://www.esreality.com/post/2242102/can-changing-hz-affect-my-usb-ports/

Quote:
If you have a legacy device (old printer/scanner) they can be subject to overheating if you inadvertently set their ports polling rate to 500/1000Hz.
Particularly inside older scanners (which run quite hot due to the light source), the circuitry containing the small buffer and I/O gubbins is usually an afterthought, crammed into a corner of the device with no ventilation. As a result they run rather hot/marginal in the first place, and giving them more work to do with the higher polling rate causes more heat and is/was enough to send them over the edge :(

Similar problems happen with cheap 4 port USB adapters which draw power from the port itself; they can easily overheat and worse can even draw too much power from the port (when several devices are connected, all trying to run at 250hz etc) where in the best case the port gets turned off, worst being it burns out the circuitry driving that cluster of ports on the motherboard.

In short, it's not just a case of 'telling the OS to poll the port at xxx times a second' ; if your not careful bad shit can happen.

You CAN damage peripheral(s) and the motherboard itself permanently if you are careless.

Fascinating! So hopefully all the reports of people damaging stuff were people on older hardware where they were overclocking ALL USB ports and probably inadvertently heating up components and then overloading the entire USB bus.

So as you can probably tell by now, I have definitely decided to go ahead and try this!!!

I think my first thing to do before installing it, is to do a little test run in Outzone of my movement with the USB keyboard, doing a bunch of fast movements, so I can get a feel for how it currently is.

OK, it's fast but it definitely doesn't seem instantaneous.

So I tried doing the HIDUSBF method. First I tried it with the Keyboard. There is a nice little utility just referred to as "setup.exe", but is actually called "USB Mouse Rate Adjuster setup". It seems to be targeted at Mice, but you can uncheck a little box called "Mouses only", and it shows the other USB devices and gives you the option of changing their USB polling rates.

So I changed the keyboard to 500hz. Rebooted the computer. Now the keyboard won't respond! Not even numlock or capslock. So I changed it to a different USB port. It re-installed the drivers and worked fine, but according to the utility,  it was no longer overclocked. Put it back in the original port, and it showed up again and said it was overclocked, but again it just didn't respond.

Next I tried overclocking my gamepad (and setting my keyboard back down to regular speed). Rebooted again. This time, the keyboard still doesn't work on that USB port, and the gamepad no longer responds either. Doh.

So I set the gamepad back to stock. Rebooted. It works again, but keyboard still not responding on that usb port.

Just out of curiosity, I wanted to make sure that USB port is still functioning! Plugged in a $20 android phone I got the other day to use as an mp3 player. It is charging and syncing fine.

Weird about the keyboard and that port then.

SO...   I'm stuck wondering, did I do something wrong, or is it not working because these utilities are primarily designed for mice?

Now to do a little search about gamepad/joysticks...

Unfortunately I can't really find anybody trying to do this specifically with gamepads/joysticks. I found a little info about a keyboard, but that's about it.

Also unfortunately, I tried one more time to make it work with the gamepad, and now I'm having the same problem, I can't get the gamepad to work on that specific USB port anymore.

:(

At this point I'm just ready to give up and see if I can reverse the changes so I can at least use these device/port combinations again.

I was about to say "Thank the gods of Toaplan, there's a way to uninstall it!", but unfortunately, uninstalling it still didn't fix the problem.

Ironically, the gamepad works in the port that won't see the keyboard, and the keyboard works in the port that won't see the gamepad. But those particular device/port combinations are now somehow blacklisted and I'm not really sure how to fix them.

Oops.

Oh well.

I guess it's better than actually frying my motherboard   :)

I'm done tinkering for now. Later on I'll try to find a permanent solution to get my ports working again.

In the meantime, I'm not sure whether I would recommend trying this in Linux. Given that everything is about 4x more difficult and time consuming in Linux, then I can see this being a total waste of time. But maybe it would somehow be easier. I don't know.

Anyway.

I tried, but ultimately failed. No 6ms input increase for me.... TODAY at least!

May the quest for more power continue!

3 comments:

  1. P.S... If you've never seen that show, he was a handyman who always wanted to add more power to whatever project he was working on... Here is a good example:

    https://www.youtube.com/watch?v=7UD1VCJvoDQ

    Haha.

    And his signature noise was this grunt he did like "ar ar ar"...
    https://www.youtube.com/watch?v=0V9YZ7C88iU

    Haha, good classic TV from the early 90's

    ReplyDelete
  2. There was one where he was talking to his son and the son said his computer was slow... And immediately he was like "URHHG? Let's juice this thing up!" ... It was hillarious, but I can't find the clip right now

    ReplyDelete
  3. Also one more thing to note, at 125mhz the input latency isn't always 8ms, it is a random number between 0ms and 8ms. I read this on some forums and it makes sense...

    Since it is being polled every 8ms, let's say you press a key 6ms after the last poll, then there is only 2ms until the next poll.

    It actually sounds like inputs would be weird with this wild inconsistency, but ms are so short it's likely our brains don't even notice.

    But I still wonder whether it would be better with 2ms range instead of 8ms....

    ReplyDelete