Jump to content
IGNORED

An Experiment for Mac Users


umea101

Recommended Posts

The first time I tried this I hardly heard a difference. Tonight I did

1. renice ITunes

2. renice Core Audio

3. renice Amarra

 

4. enjoy

5. enjoy

6. enjoy

...

Cant get the grin off of my face. I am glad I tried it again.

 

More Details, better separation of instruments. Less digititis... (read the other posts, I can confirm that) ... and what is most important the music is much more involving. I try not to get carried away and will report after I did a restart of the system and tried it again. Right now, I do not want to change anything.

 

Link to comment

If Core Audio is not showing up in Activity Monitor, it probably is because the "Show" popup menu to the left of the filter field is set to "My Processes". You should change it to "All Processes".

 

Because Core Audio runs under its own User ID, you can renice it without even looking up its Process ID. Instead, simply renice the Core Audio user "_coreaudioid". The required command is in my earlier post in this thread on 12/03/2009 - 10:59 PST:

 

In AppleScript:

do shell script "renice -20 -u _coreaudiod" with administrator privileges

 

In Terminal:

sudo renice -20 -u _coreaudiod

 

HQPlayer (on 3.8 GHz 8-core i7 iMac 2020) > NAA (on 2012 Mac Mini i7) > RME ADI-2 v2 > Benchmark AHB-2 > Thiel 3.7

Link to comment

When you do a renice.... do you have to RE-renice if the computer goes to sleep and wakes back up?

 

What about if you close iTunes and/or Amarra, do you have to RE-renice coreaudio when you open them back up?

 

Also can someone post the complete script that would automate all of this when an application is started.

 

For example if you start iTunes will you be able to click on a icon which controls the script which renice's iTunes, coreaudio, etc.

 

 

 

Link to comment

While it won't work for coreaudio you can always start iTunes with nice then there is no worry about determining PID etc...

 

 

command removed until I sort how to work around a "small" issue - Tunes runs as root and can't access user library.

 

To "fix" coreaudiod so it runs at higher priority at every startup add:

 

 

Nice

-20

 

 

above the closing tag in /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist

This change needs to be done with Admin privileges and it's probably a good idea to make a backup of the original file.

 

The change to the coreaudiod.plist takes effect after reboot (or unload/reload with launchctl - it's almost quicker to reboot). It's worth checking the added keys are still in place after OS updates.

 

cheers

Paul

 

 

Link to comment

Ok nice is only suitable for root owned applications....

 

What I was looking for was a means of launching iTunes and having it run with higher priorities without having to manually mess with terminal. I came across some code that used ps and grep to find an apps PID and after a couple of tweaks and a lot of trimming I ended up with this bit of applescript:

 

tell application "iTunes" to activate

set iTunesPID to do shell script "ps -axww | grep '[/]iTunes '| awk '{print $1}'"

do shell script "sudo renice -15 -p " & iTunesPID user name "YourName" password "YourPassword" with administrator privileges

 

 

If you paste into Applescript Editor and change YourName and YourPassword to your username and login password respectively, then save as an app you should be able to launch and renice iTunes with one click. I'd suggest using "get info" to set Sharing & Permissions so "everyone" has no access, and storing the app somewhere secure - your Documents folder perhaps.

 

cheers

Paul

 

NNB: I had to add a space between end of "iTunes" and the closing quote of the grep statement to stop grep returning the PID for Itunes AND iTunesHelper.

 

Link to comment

Did you test your AppleScript while you were logged into a non-admin account? I don't think the sudo command works with a non-admin username. Also, "sudo" and "with admin privileges" are redundant. Since embedding an admin username and password in a script is a security risk, perhaps the best approach is to omit the username and let the system ask for an admin username and password when you run the script. That would shorten that line of code to:

do shell script "renice -15 -p " & iTunesPID with administrator privileges

 

Also, to be sure iTunes launches before you execute the next line of code, you could insert the following code between the 1st & 2nd lines of your script:

repeat 8 times

if application "iTunes" is running then

exit repeat

else

delay 1

end if

end repeat

 

HQPlayer (on 3.8 GHz 8-core i7 iMac 2020) > NAA (on 2012 Mac Mini i7) > RME ADI-2 v2 > Benchmark AHB-2 > Thiel 3.7

Link to comment

Bob,

 

Thanks, I had meant to remove the "sudo" from the posted version. I'd done so on my working copy here.

 

I wrote the script for a use on a headless mac mini with a single admin account. I have iTunes set to start up at login - login is set to automatic - and want to start iTunes reniced without human intervention. That is what the script does :) You are welcome to modify as you see fit.

 

I haven't seen any issues with start up on either my mid '09 MBP or core solo mini. If you are concerned by all means add the delay, but I suspect it won't be needed.

 

regards

Paul

 

Link to comment

Thanks Paul and Bob.

 

I assume you can put a line in the script to renice 'coreaudio' as well? Or does it automatically happen?

 

Also, another assumption....I could replace iTunes with any program in the script say Amarra for example?

 

 

 

Link to comment

If my understanding is correct, the “sudo renice” terminal command can be used to increase the priority of a process being performed in Mac OS X. I’m running Mac OS X version 10.5.8.

 

If we perform this terminal command, processes with lower "nice" values will be given higher priority. Since lower nice values translate into higher priority, the process should, theoretically, receive a greater share of the computer’s processor time. Conversely, processes with higher nice values will receive lower priority, and this should result in less processor time.

 

In terms of scale, my understanding is that nice values range from -20 to +19. Therefore, since -20 is the lowest possible nice value, processes with a -20 nice value should have absolute priority and receive the most processor time.

 

That being said, here are my questions:

 

1. Assuming we are only running iTunes and the processor is not taxed or over-burdened with multiple demanding applications, why is it necessary to override the logic of Mac OS X? If there is plenty of processor headroom, will iTunes and Coreaudio benefit from a lower nice value? Assuming there is plenty of available processor time to properly run all applications, why should the order or schedule make a difference?

 

2. Assuming there are audible benefits, why should both iTunes and Coreaudio be assigned the same nice value? If -20 is the lowest possible value, will iTunes and Coreaudio be in constant competition for the most processor time? In an effort to reduce competition, is it better to assign a value of -20 to Coreaudio and -19 to iTunes?

 

3. I have seen at least two variations of sudo nice terminal commands. Does anyone know if there are any differences between the following?

sudo renice -20 pid

sudo renice -20 -p pid

The second version includes “-p” before the pid. Does this make a difference and, if so, why?

 

Thank you very much in advance.

 

Best regards,

Chris

 

 

Amarra 3.0.3/iTunes-->AQVOX USB PS-->Acromag USB Isolator-->Ayre QB-9-->Ayre K-5xeMP-->W4S SX-500-->Tyler Acoustics Linbrook Super Towers-->SVS SB12-Plus (L&R). Cables: Nordost, Transparent, LessLoss, Analysis Plus & Pangea. Dedicated line with isolated power conditioning per component: PS Audio & Furman. Late 2012 Mac Mini 2.6GHz Quad-Core i7 (16 GB, 1TB Fusion, 6TB ext via Tbolt). External drives enclosure http://www.computeraudiophile.com/f7-disk-storage-music-library-storage/silent-enclosure-external-hard-drives-7178/

Link to comment

Dynobot

 

I've modded the plist that controls coreaudiod to start it with "nice -20". It would be just as easy to duplicate the line for iTunes and change the iTunesPID to coreaudioPID. You would also need to change the grep search term to coreaudiod.

 

Chris,

 

I think the idea is that there a number of background tasks that run without user intervention. If you are using screen sharing to admin a headless computer there are a number of process running to support that. The window server which renders the display is always running. Pop open a terminal and run ps -ev and you'll get a list of running processes. Increasing the priority of coreaudio and itunes ensures that these tasks are given priority to resources.

 

I'd suggest that coreaudio and itunes share equally in the task of delivering audio and neither should be have higher priority than the other. I don't think this is a case of "fighting" more that the task scheduler assigns equal processor time to competing tasks.

 

-p indicates that the following argument is the PID of the process you wish to renice. Both forms work on OSX but using -p make it clear that your are specifying a PID rather than a GID or an increment. Perhaps "sudo renice -n -20 -p PID" is the clearest form to use.

 

cheers

Paul

 

Link to comment

Hi Paul,

 

Thank you for taking the time to respond. I appreciate your feedback and you seem to be very knowledgeable about OSX command language.

 

As you pointed out, a number of system processes run at all times. Using Activity Monitor, I count 51 processes that automatically start and run in the background after performing a system re-start. After re-start, CPU usage is about 97% idle (this fluctuates to a certain degree). This implies that background tasks account for approximately 3% of CPU usage with my system.

 

When I launch iTunes, CPU usage increases and idle percentages dip to about 80%. Shortly thereafter, idle percentages return to about 95%.

 

When I play a 123MB 24/96 AIFF audio file with iTunes, CPU usage spikes for a moment and idle percentages dip to about 64%. After the song plays for a few moments, idle percentages quickly increase and they generally fluctuate between 80% and 95%.

 

My iMac system has the following specs:

2.66GHz Intel Core 2 Duo

4GB memory

700GB internal hard drive (no material storage)

Glyph 2TB external hard drive connected via FW800 (exclusive iTunes Library)

Benchmark DAC1 Pre connected via USB

 

Since CPU usage fluctuates dramatically in some cases, it may indeed help to instruct the task scheduler to prioritize processor time to iTunes and Coreaudio. In my case, it seems that priority will help the most when initializing a hi-rez audio track.

 

I’m currently experimenting with your suggested command language for both iTunes and coreaudiod. My listening tests include nice values that range from -5 to -20. While I do not have conclusive feedback at the moment, I consider this approach worth exploring.

 

On a side note, I sincerely hope that my questions didn’t appear confrontational or “loaded” in a negative way (respectful nod to indirstr8s). I can appreciate how easy it is to take a long list of questions the wrong way. For the record, I’m open to, and interested in, all possible approaches that may improve or enhance our computer audio experience. CA has been a fantastic resource and I value the many contributions herein.

 

Cheers,

Chris

 

 

 

Amarra 3.0.3/iTunes-->AQVOX USB PS-->Acromag USB Isolator-->Ayre QB-9-->Ayre K-5xeMP-->W4S SX-500-->Tyler Acoustics Linbrook Super Towers-->SVS SB12-Plus (L&R). Cables: Nordost, Transparent, LessLoss, Analysis Plus & Pangea. Dedicated line with isolated power conditioning per component: PS Audio & Furman. Late 2012 Mac Mini 2.6GHz Quad-Core i7 (16 GB, 1TB Fusion, 6TB ext via Tbolt). External drives enclosure http://www.computeraudiophile.com/f7-disk-storage-music-library-storage/silent-enclosure-external-hard-drives-7178/

Link to comment

If you don't want to modify your CoreAudio property list, there's a couple alternatives.

 

One is to include a renice command in an AppleScript application that also launches your media player. As suggested previously, something like this:

 

do shell script ("renice -20 -u _coreaudiod") user name "YourName" password "YourPassword" with administrator privileges

 

If you save this as a Run Only Application in the AppleScript Editor, your personal settings are pretty secure. But, as was mentioned previously, you can eliminate the 'user name "YourName" password "YourPassword"' part and you will be promoted to enter your password.

 

This one line short program can be saved as an Application, moved to some folder like Utilities or wherever you keep these things, and then you can add it to the Login Items list for your account in System Preferences. That will give CoreAudio maximum priority whenever you start your computer.

 

You also don't need to use a GREP search to determine a process ID. Something like this will work:

 

tell application "System Events" to set unixID to unix id of process "Play"

do shell script ("renice -20 " & unixID) with administrator privileges

 

There's also a *free* utility that will allow you to set process priority on the fly and also see what priority your existing processes are set to.

 

http://www.lachoseinteractive.net/en/products/processwizard/

 

Heed their words about terminating processes you don't know anything about!

 

Link to comment

While this

 

do shell script ("renice -20 -u _coreaudiod") user name "YourName" password "YourPassword" with administrator privileges

 

worked just perfectly under Snow Leopard, I tried it on a Leopard based machine and it failed. The error was something like, "Didn't recognize the UID of _coreaudiod"

 

Any ideas??

 

Link to comment

It looks like coreaudiod runs under a UID of the root user and there is no user _coreaudiod under 10.5. So renicing coreaudiod needs to be done by PID under 10.5 and 10.4. The easy solution for something that works on 10.4,10.5,10.6 is to use grep to grab the PID.

 

I'd also note the saving the script as a run only app is only marginally more secure the leaving the password in textfile. You can open the app by right clicking and selecting show package contents. You can then open the script in Applescript Editor with no problems. Best keep the app in a location that is accessible to the logged in admin user ie Documents.

 

cheers

Paul

 

Link to comment

Using grep is not necessary for learning the Unix ID of an application like iTunes. As I said previously. Sorry if that confused you.

 

If you save an AppleScript as a *Run Only* Application, then you shouldn't be able to open it with AppleScript Editor. As I said previously. Sorry if that confused you.

 

I just tried opening the package contents for a Run Only AppleScript Application, and got the message that I couldn't. If you can open it with AppleScript Editor, you're a far better man than I am.

 

This is not fun.

 

Link to comment

After experimenting with ‘sudo renice’ commands, I’m experiencing system delays. When rebooting, desktop icons do not appear and there is a spinning pinwheel while the desktop attempts to load. Also, certain programs, like Word, take much longer to load and the same spinning pinwheel appears. Tasks that were fast and close to instantaneous before, now take 20 to 30 seconds to process.

 

More background and questions...

 

As expected, the PID for iTunes and coreaudiod change after each system re-start. I’m assuming that this is why we have to renice again after rebooting. However, what happens to the old PIDs that were previously reniced...have they been reset after re-starting, or are their nice values still -20?

 

For example, the PID for iTunes was 145. After rebooting, the PID (for iTunes) changed to 370. PID 145 no longer appears in Activity Monitor and I’m assuming this is the case because the PID has not been assigned to a given process.

 

If we renice a PID with a value of -20, then re-start, will unassigned Process ID still have a nice value of -20? If so, could the system get bogged down looking for high priority PIDs that have not been assigned to a process? Since I have been experimenting a fair amount with sudo renice commands for both iTunes and Coreaudio, there may be a lot of PIDs with values of -20 that do not appear in Activity Monitor.

 

Is there a way to undo all of the renice commands that I have performed? I would like to check if system performance returns to previous levels.

 

Also, has anyone else had a similar experience?

 

Thank you in advance for your help.

 

Best regards,

Chris

 

 

Amarra 3.0.3/iTunes-->AQVOX USB PS-->Acromag USB Isolator-->Ayre QB-9-->Ayre K-5xeMP-->W4S SX-500-->Tyler Acoustics Linbrook Super Towers-->SVS SB12-Plus (L&R). Cables: Nordost, Transparent, LessLoss, Analysis Plus & Pangea. Dedicated line with isolated power conditioning per component: PS Audio & Furman. Late 2012 Mac Mini 2.6GHz Quad-Core i7 (16 GB, 1TB Fusion, 6TB ext via Tbolt). External drives enclosure http://www.computeraudiophile.com/f7-disk-storage-music-library-storage/silent-enclosure-external-hard-drives-7178/

Link to comment

Hi!

 

I can imagine that things become slower once you assigned priority to the audio programs, although I did not notice any difference on a dual core iMac. Anyway this should be gone on reboot. As you have noticed new PIDs are assigned and the previous nice value forgotten.

 

Seems like the problem is elsewhere. I would check the activity monitor what is eating the processor time.

 

Link to comment

If you renice or nice a PID the change lasts only until you reboot. After reboot all task will be at default priority until you invoke nice/renice.

 

To revert renice you should be able to renice -n 0 -p PID. This simply renices the process to the default priority of 0.

 

You'll have a better idea of what is running and what priority each task is assigned if you use ps -el rather than top. You'll probably need to expand the width of your terminal window to see all the detail, but you'll get processes sorted by PID and the NI column displays current priority.

 

Unless you have reniced/niced a process prior to login, by altering the plist for example, there should not be any effect on rendering of desktop or application start up. If you are renicing iTunes and Coreaudio and playing music when you start Apps that will definitely impact Word startup times.

 

To be honest I wouldn't recommend renicing processes to -20 on a machine that is not a dedicated music server.

 

Link to comment

Based on the various comments/suggestions, here is what I came up with.

 

****

 

tell application "Amarra Mini" to activate

repeat 8 times

if application "Amarra Mini" is running then

exit repeat

else

delay 1

end if

end repeat

set iTunesPID to do shell script "ps -axww | grep '[/]iTunes '| awk '{print $1}'"

do shell script "sudo renice -18 -p " & iTunesPID user name "UserName" password "UserPassword" with administrator privileges

set AmarraPID to do shell script "ps -axww | grep '[/]Amarra Mini '| awk '{print $1}'"

do shell script "sudo renice -19 -p " & AmarraPID user name "UserName" password "UserPassword" with administrator privileges

do shell script "renice -20 -u _coreaudiod" with administrator privileges

 

***

 

Note: change "UserName" & "UserPassword" as appropriate.

 

This starts up Amarra Mini which also starts iTunes.

 

I used various renice values for each process (Core Audio, Amarra Mini, iTunes). No logic behind this other than not wanting to set them to all the same value. I did check with "ps -el" and the renice commands do work properly.

 

I saved this as an application and placed it on the Dock so I use this to launch Amarra Mini which in turn launches iTunes. Seems to work as advertised on MacBook Pro running Snow Leopard.

 

I am a programming hack, not a real programmer, so if a real programmer has suggestions, please provide input.

 

Eric

www.beresford-dac.com

 

Link to comment
  • 3 weeks later...

I'm having trouble getting this to work. Is all this still applicable since I'm using Snow leopard? Or is this only applicable for older OS?

 

Thanks!

Robert

RSAD

 

Robert[br]Ridge Street Audio Designs[br]\"The reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. Therefore, all progress depends upon the unreasonable man.\" [br]George Bernard Shaw

Link to comment

This does work under SL.

 

Based on some research and posts to another thread I'd recommend against renicing coreaudiod. It appears that coreaudiod manages system sounds and alerts. Disabling coreaudiod has no effect on iTunes playing to the default output but built-in output is no longer available as an output for system sounds. This indicates there will be zero benefit from changing priority on coreaudiod.

 

Cheers

Paul

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...