Question about CPU (SOLVED)

Post fully complete "how to" guides and tutorials here. This is a great place to get feedback on stuff you might put in the wiki.

Moderators: MattKingUSA, khz

User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Question about CPU

Post by autostatic »

briandc wrote:Can I change any of this to reduce the xruns even more? (I don't get many, but they do happen at times...
Probably not but you might be able to prevent xruns from happening by tweaking other settings. More info in the LinuxMusicians Wiki: http://wiki.linuxmusicians.com/doku.php ... figuration

In your case, what soundcard are you using? And what is the output of the terminal commands cat /proc/interrupts and cat /proc/asound/cards ?
And regarding the ulimit thing you're running Ubuntu right? In that case, try running sudo dpkg-reconfigure jackd2 . If it asks you if you want to enable realtime process priority select Yes.
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

AutoStatic wrote:
briandc wrote:Can I change any of this to reduce the xruns even more? (I don't get many, but they do happen at times...
Probably not but you might be able to prevent xruns from happening by tweaking other settings. More info in the LinuxMusicians Wiki: http://wiki.linuxmusicians.com/doku.php ... figuration

In your case, what soundcard are you using? And what is the output of the terminal commands cat /proc/interrupts and cat /proc/asound/cards ?
And regarding the ulimit thing you're running Ubuntu right? In that case, try running sudo dpkg-reconfigure jackd2 . If it asks you if you want to enable realtime process priority select Yes.
Hi AutoStatic,
I'll check the link you gave.
I'll be back at that PC tonight (I'm in Italy, so I think we have the same timezone..), and I'll run the info on the sound cards.
Admittingly, I'm using a PC with an internal sound card, of not great quality. I'm doing things on it just to see how much performance I can get out of it. Obviously, the best thing would be to get an external sound card, but I'm not going to bother since I have another PC with more powerful resources.
And, since this PC in question is limited in resources, I've installed AntiX, which I like a lot because it's particularly fast on older PCs. And so it's fast and light for making music.
And, when I installed Jack2, it asked if I wanted realtime, and I selected "yes," and QJackCtl indicates this.
My question at this point is, are there other things that I can tweak to clean out xruns, such as changing priorities somewhere, or doing something like what this guy mentions:
http://www.akjmusic.com/linuxaudio.html

What do you think?


brian
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
Pablo
Established Member
Posts: 1274
Joined: Thu Apr 17, 2008 9:57 pm
Been thanked: 3 times

Re: Question about CPU

Post by Pablo »

And, when I installed Jack2, it asked if I wanted realtime, and I selected "yes,"
OK, but that is not enough. Now you have to add your username to the audio group. Do in a terminal:

Code: Select all

sudo adduser your_user_name audio
And restart the computer. Now, "ulimir -r -l" should say rtprio ninety-something and memlock unlimited.

Cheers, Pablo
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Question about CPU

Post by autostatic »

briandc wrote:Admittingly, I'm using a PC with an internal sound card, of not great quality. I'm doing things on it just to see how much performance I can get out of it.
If it's something like an Intel HDA onboard thingy you can still achieve a reasonable latency. Afaik these kind of onboard cards work best with the following JACK settings:
  • Frames/Period: 128 (you could try going lower, maybe it works)
  • Sample Rate: 48Khz
  • Periods/Buffer: 2
briandc wrote:My question at this point is, are there other things that I can tweak to clean out xruns, such as changing priorities somewhere, or doing something like what this guy mentions:
http://www.akjmusic.com/linuxaudio.html
Turning off ACPI is not necessary in most situations. Tuning your hard drive is uncharted territory for me, I'll add it to the to-do list in the Wiki. Tuning the PCI bus is not necessary in your case I think, unless the Intel HDA soundcard is sitting on an old-school PCI (so not PCIe) bus. But more info on PCI bus latency can be found here: http://wiki.linuxmusicians.com/doku.php ... us_latency
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

Pablo wrote:
And, when I installed Jack2, it asked if I wanted realtime, and I selected "yes,"
OK, but that is not enough. Now you have to add your username to the audio group. Do in a terminal:

Code: Select all

sudo adduser your_user_name audio
And restart the computer. Now, "ulimir -r -l" should say rtprio ninety-something and memlock unlimited.

Cheers, Pablo
I had checked the GUI for users before, but I was in doubt so I ran the command you posted here. But indeed, I am already part of the audio group.

Does locking/unlocking memory have any effect?
What about priority changes? QJackCtl is set to "default" but maybe that's not enough?

Also, I notice that an occasional xrun happens even when I'm not recording. Sometimes opening an app will cause one!

brian
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
Pablo
Established Member
Posts: 1274
Joined: Thu Apr 17, 2008 9:57 pm
Been thanked: 3 times

Re: Question about CPU

Post by Pablo »

I had checked the GUI for users before, but I was in doubt so I ran the command you posted here. But indeed, I am already part of the audio group.
To sum up,

1) You are in the audio group
2) The lines
@audio - rtprio 95
@audio - memlock unlimited
are present in either /etc/security/limits.conf or in some file under /etc/security/limits.d (tipically /etc/security/limits.d/audio.conf)
3) But still you don't have rtprio and memlock privileges, as shown by "ulimit -r -l" or in qjackctl and ardour messages.

Some users had this exact problem when using a light login manager (slim) that wouldn't load the pam_limits PAM module. See

http://linux.die.net/man/8/pam_limits
http://meandubuntu.wordpress.com/2008/0 ... -and-jack/

rtprio and memlock are a must. Other tweaks can help but you need to solve that first.

Cheers, Pablo
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Question about CPU

Post by autostatic »

briandc wrote:Does locking/unlocking memory have any effect?
Highly doubt it.
briandc wrote:What about priority changes? QJackCtl is set to "default" but maybe that's not enough?
You could give it a try. I mostly use 70, but that also depends of the other prios set on the system (I also use rtirq and have to make sure no prios overlap each other which defeats the purpose of using prios).
briandc wrote:Also, I notice that an occasional xrun happens even when I'm not recording. Sometimes opening an app will cause one!
That shouldn't happen. What kind of Desktop Environment are you using (Gnome3, KDE, Unity, XFCE)?
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

Pablo wrote:
To sum up,

1) You are in the audio group
Correct.
Pablo wrote:2) The lines
@audio - rtprio 95
@audio - memlock unlimited
are present in either /etc/security/limits.conf or in some file under /etc/security/limits.d (tipically /etc/security/limits.d/audio.conf)
Correct.
Pablo wrote:3) But still you don't have rtprio and memlock privileges, as shown by "ulimit -r -l" or in qjackctl and ardour messages.
Correct.
Pablo wrote:Some users had this exact problem when using a light login manager (slim) that wouldn't load the pam_limits PAM module. See

http://linux.die.net/man/8/pam_limits
http://meandubuntu.wordpress.com/2008/0 ... -and-jack/

rtprio and memlock are a must. Other tweaks can help but you need to solve that first.

Cheers, Pablo
I don't know what I should do to the pam_limits.so file. It's basically blank.
But my problems aren't as "severe" as mentioned in the second link (Jack not working at all).

However, I did notice in the "/etc/security/limits.d/audio.conf" file that the renice function was not activated. Perhaps I should activate it?

brian
Last edited by briandc on Mon Jun 11, 2012 7:55 pm, edited 1 time in total.
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

AutoStatic wrote:
briandc wrote:Does locking/unlocking memory have any effect?
Highly doubt it.
briandc wrote:What about priority changes? QJackCtl is set to "default" but maybe that's not enough?
You could give it a try. I mostly use 70, but that also depends of the other prios set on the system (I also use rtirq and have to make sure no prios overlap each other which defeats the purpose of using prios).
briandc wrote:Also, I notice that an occasional xrun happens even when I'm not recording. Sometimes opening an app will cause one!
That shouldn't happen. What kind of Desktop Environment are you using (Gnome3, KDE, Unity, XFCE)?
I'm using the IceWM environment.

What about the renice command? Is that the same as prios? How can I know what prios are already set? I know that running

Code: Select all

top
gives the nice settings. I also saw in the audio.conf file that the renice setting of -19 was ready but not activated..

brian
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

I'm supposing that I should open the limits.conf file as root, and put:

as domain: brian
as type: hard
as item: memlock
as value: unlimited

-and-


as domain: brian
as type: hard
as item: rtprio
as value: 95


Correct? :)

brian
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
Pablo
Established Member
Posts: 1274
Joined: Thu Apr 17, 2008 9:57 pm
Been thanked: 3 times

Re: Question about CPU

Post by Pablo »

I also saw in the audio.conf file that the renice setting of -19 was ready but not activated..
According to Paul Davis, nicety is irrelevant for realtime processes. Activating that line won't hurt but it won't help either.

And no, you don't have to further edit security limits conf.

Instead, take a look at /etc/pam.d/

there should be a "login" file of some sort. Write this line:

session required pam_limits.so

Cheers, Pablo
Pablo
Established Member
Posts: 1274
Joined: Thu Apr 17, 2008 9:57 pm
Been thanked: 3 times

Re: Question about CPU

Post by Pablo »

But my problems aren't as "severe" as mentioned in the second link (Jack not working at all)
jack2 (the "modern" jack, so to speak) is more tolerant with system configurations and it works without realtime privileges. jack1 (the default jack at the time of the writing) wouldn't even start.
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

Pablo wrote:
I also saw in the audio.conf file that the renice setting of -19 was ready but not activated..
According to Paul Davis, nicety is irrelevant for realtime processes. Activating that line won't hurt but it won't help either.

And no, you don't have to further edit security limits conf.

Instead, take a look at /etc/pam.d/

there should be a "login" file of some sort. Write this line:

session required pam_limits.so

Cheers, Pablo
I found the "login" file you suggested.
And the line: session required pam_limits.so was already inserted.

Now, from what I read in this file, it appears that pam reverts to what is written in the limits.conf file.

So I'll try adding the lines I mentioned in my last post, just to see if that improves anything, and I'll let you know how it goes..

brian
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
User avatar
briandc
Established Member
Posts: 1442
Joined: Sun Apr 29, 2012 3:17 pm
Location: Italy
Has thanked: 58 times
Been thanked: 28 times
Contact:

Re: Question about CPU

Post by briandc »

I'm back..

well, adding the two lines didn't "seem" to make much difference.
BUT, I do see that setting QJackCtl at 32000Mhz rather than 41000 Mhz keeps the xruns very low indeed.
In addition, I used the "renice" command (at root) to set QJackCtl at about -18, and a2jmidid and yoshimi (or other synth) at about -16. I think renicing has to be done at every boot, but that's ok.

Audour still gives me the memlock warning, but it does the job.

My (last?) problem at this point, is to figure out why Audacity doesn't "see" the signal coming from Jack. When I hit record, it crashes. It might be a setting that's off, in the ALSA mixer, but I don't know where or what...

brian
Have your PC your way: use linux!
My sound synthesis biome: http://www.linuxsynths.com
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Question about CPU

Post by autostatic »

briandc wrote:Perhaps I should activate it?
No, that's not necessary:
You could also allow the audio group to renice processes with the help of the limits.conf file, but since nice uses SCHED_OTHER it basically does nothing to increase the performance of a low-latency real-time audio environment that relies on SCHED_FIFO/SCHED_RR. Consult the sched_setscheduler manpage for more info on this subject.
From: http://wiki.linuxmusicians.com/doku.php ... audio.conf

In other words: using renice improves nothing.

And since you're using IceWM that rules out the desktop environment as a possible troublemaker. I've used IceWM for quite a while too, very light-weight and easy to configure with flat-file, ini-style configuration files. Good choice for doing audio stuff. But what kind of display/login manager are you using?

Regarding Audacity:
  • Start JACK
  • Start Audacity
  • Tick View - Toolbars - Device Toolbar
  • In the Device Toolbar select 'JACK Audio Connection Kit' with the 'Audio Host' combo box (default is ALSA)
briandc wrote:How can I know what prios are already set?

Code: Select all

ps -eLo pid,cls,rtprio,cmd
Also in the WIki: http://wiki.linuxmusicians.com/doku.php ... tion#rtirq
Post Reply