-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust controller polling frequency with the audio buffer #6383
Comments
Commented by: noname2-deactivatedaccount wow my laptop is getting hot over 100% cpu usage while doing nothing |
Commented by: albeu Here is the patch to get the polling frequency back to the old setting. |
Commented by: Pegasus-RPG I'd like Mixxx to auto-detect whether a system can support a 1ms timer and automatically use it if so. Does anyone know of a way to do this? Qt doesn't seem to have any mechanism. |
Commented by: Pegasus-RPG Or, ideally, we patch PortMIDI to use a callback-based system, truely solving the problem. |
Commented by: albeu Moving away from polling would be the ideal solution, but I don't know if the PortMIDI API allow it. Otherwise, regarding linux, getting the HZ value of the currently running kernel doesn't seems to be straightforward. Dunno how it's like on other systems, but making the poll frequency configurable is probably the simplest. |
Commented by: pwhelan Neither PortMidi nor RtMidi support any of the event based I/O APIs on any of the platforms or a blocking poll call. This might actually be a portability problem. As quoted from the PortMidi Doxygen docs at http://portmedia.sourceforge.net/portmidi/doxygen/group__grp__io.html#ge88e6c682ee3550defdd0c74bcbdd508: "with a lock-free fifo, which is pretty much what we're stuck with to enable portability to the Mac, it's tricky for the producer and consumer to synchronously reset the buffer and resume normal operation." |
Commented by: Pegasus-RPG Does a lock-free FIFO prevent blocking (for a set amount of time) until a message is received like HIDAPI does? |
Commented by: raskolnikov I suffer the same problem, and I am running on a 1000HZ custom kernel. |
Commented by: bkgood
|
Commented by: bkgood Bleh so much for my lovely table. Basically, without my changes, I see 150%/110% CPU usage under load/idle. With the patch, it's 70%/35% (the under load figure doesn't include any analyzers). |
Commented by: bkgood If someone whose system is noticeably heated by the unrestricted polling can test this it'd be much appreciated, I'm in the process of moving country so I just had enough time to write a fix and watch htop for a few minutes. |
Commented by: rryan Can you give the load/idle numbers for no MIDI device enabled? (that way we On Mon, May 21, 2012 at 1:54 PM, Bill Good wrote:
|
Commented by: xorik I can confirm, mixxx from lp:~mixxxdevelopers/mixxx/fixes_midi_burnout not uses more then 100% CPU, when controller is pluged in! |
Commented by: rryan Also, I don't really see why you use QThread::msleep(1) instead of just On Mon, May 21, 2012 at 2:27 PM, RJ Ryan wrote:
|
Commented by: noname2-deactivatedaccount come on guys just revert it to 250hz or lower. it should be enough |
Commented by: bkgood
12% idle/55% load. I have no issue with simply increasing the polling interval.
It only sleeps when the poll didn't see any data. So if mixxx starts taking in a stream of data (scratching), it'll hopefully not sleep. It does increase latency from no data to data though, which will be common scenario (no midi input to hitting a button, for instance). Honestly I thought there were limitations of midi over usb that prevented data from coming in at 1ms intervals so this could all be for naught. |
Commented by: albeu
I fully agree. I'm using the current trunk with 250Hz and it work Alban |
Commented by: zestoi i like bill's method - it does seem to be exactly how rtmidi handles the same thing, to emulate blocking nreads and callbacks. |
Commented by: rryan There are other parts of Mixxx that we use a 1ms timer, for example in the script-engine scratch timers. @juliusvonkohout we are searching for the right fix. "just reverting it" doesn't give us any useful information about how to avoid issues like this in the future. High-frequency timers are a very necessary part of getting rid of latency in Mixxx and making it more responsive. @Bill -- we must be missing something... if RtMidi sleeps for 1ms when no input is available then we are sleeping strictly /more/ often than RtMidi (we sleep 1ms regardless of whether input is available) so where is the difference? |
Commented by: albeu
Reliable timer with 1ms accuracy are just not possible without a If the design really require such high frequency timer it is a big flaw Alban |
Commented by: rryan Hi Alban -- while it's true that without a realtime kernel you lose out on Using basic timing primitives like select() is bad because you tie yourself To address your point about scheduling.. we strongly suggest people enable High-resolution, accurate timing is a requirement of any DSP-heavy or On Thu, May 24, 2012 at 12:22 PM, Alban wrote:
|
Commented by: rryan In general it doesn't make sense that scheduling a timer for 1ms when the Since we're asking for a 1ms repeated timer from QTimer, is it possible On Thu, May 24, 2012 at 12:43 PM, RJ Ryan wrote:
|
Commented by: Pegasus-RPG In addition, see #8: someone with a 1000Hz kernel has the same problem. There's something else mysterious going on here. I just wish one of our devs had the problem. raskolnikov (or anyone affected by this): are you gather some profiling data for us? We would need you to build Mixxx from source with profiling=1, run it, try to use the MIDI controller for about a minute, then close Mixxx. Then run gprof ./mixxx and attach the output to this bug. |
Commented by: rryan I dug into the QEventDispatcher code a little bit and it looks like my Other interesting tidbits from reading the Qt source is that for timers
|
Commented by: albeu
Assuming the handler thread is sleeping, waiting for some event or
High resolution doesn't imply that you can use high frequency. You
This only allow fine tuning the priority between the threads, a good
Sure high resolution help a lot, but we are talking about wasting Alban |
Commented by: rryan Bill -- Hm, sleeping the controller manager thread isn't going to work since that also blocks other processing done in that thread for 1ms (e.g. midi script timers, control object changes, etc.). For 1.11.0 beta1 I'm just going to ifdef the polling frequency to 5ms for Linux. I do like your branch's changes though.. except that I think if we processed events while polling we should immediately poll again (this matches RtMidi's behavior and our 1.10.0 and below behavior). So I'm merging it now. Thanks! |
Commented by: daschuer This bug is fixed for 1.11.0 isn't it? |
Commented by: Pegasus-RPG This is not fixed in 1.11, as there's just an IFDEF that sets the polling frequency to 5ms on Linux only. Syncing the polling with the audio callback is an interesting idea, so we should explore that too. |
Duplicates: #6952 |
Reported by: albeu
Date: 2012-04-29T10:16:32Z
Status: Triaged
Importance: High
Launchpad Issue: lp990992
Tags: midi, performance
Attachments: controller-polling-frequency.patch
In the new controller manager the polling frequency is hardcoded to 1KHz, however my system (ubuntu 11.10) use HZ=250. As the timer frequency is higher than the system time slice it completely hog the cpu rendering controllers unusable. In the old system the poll frequency of PortMidi was 250Hz.
The text was updated successfully, but these errors were encountered: