Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)


What links here:

Mac maintenance

From https://superuser.com/questions/412793/my-mac-is-slow-but-dont-know-whats-slowing-it-down

WARNING! This “answer” does address the question, but also goes on to includes a whole lot more information that I hope some people can benefit from.

For many this will be known information. It may help new users, however. Having TOO MUCH experience with Macs going sluggish, the one thing I do know is that (unfortunately) there can be innumerable causes.

The above answer about Spotlight indexing is indeed one probable culprit. If the Spotlight magnifying glass icon in the very top right of your menu bar contains a small dot that subtly grows and shrinks, then Spotlight is indexing your hard drive (including the contents of each file). But in my experience, Spotlight hasn’t exacted a troublesome performance penalty while I continued to browse, email, use Photoshop, Pages, etc.

If you want, you can go to System Preferences–>Spotlight–>Privacy and click the plus symbol at the bottom left of the of the leftmost column. Add your boot drive and any other connected drives. This will stop Spotlight from indexing and consuming your storage I/O, CPU and other system resources.

Then, if you DO want Spotlight to index everything (say, while you’re sleeping) do the reverse and highlight each drive in the Privacy column and click the minus sign. Spotlight SHOULD resume, and the magnifying glass should pulsate again. (A shareware utility that allows you to delete the current Spotlight index might not be a bad idea, as Spotlight would after which start fresh and run without interference while you’re asleep.)

Spotlight takes a long time the FIRST time it indexes whole volumes, but no noticeable performance change is detectable (to me) after that, as it only incrementally indexes newly created files and data (FAR less indexing that the first run on a whole volume).

Activity Monitor has proven an indispensable tool for seeing all the “invisible” processes that are running and are not apparent to you otherwise. You may be impressed at how much is going on behind-the-scenes with Mac OS X. It REALLY IS “The Most Advanced Desktop Operating System In the World,” IMO.

In Activity Monitor, select from the pop up menu to view “All processes, hierarchically.”

Then click on the CPU column which sorts all processes according to how much CPU MHz they are using. This sorting method is not perfect as you’ll notice daemons or processes running within other processes and showing significant CPU usage, yet might not appear at the top of the sorted list as you’d expect. Also, this is real time, so the processes RAPIDLY hop up and down in the list constantly.

Besides CPU consumption, Activity Monitor shows you how many threads a process is using. A dozen or more threads means the process is allocating to itself a lot of resources. I don’t pay attention to memory consumption because it’s Virtual Memory and uses hard drive space as Virtual RAM. If you were to add up the total Virtual Memory the apps and processes in Activity Monitor claim to allocate for themselves, you’d think you’d need a terabyte of RAM installed! Virtual Memory works smoothly in the background and needs not your attention. (Thanks Avi, Bertrand, Jordan, et al.) OH! And it’s a good idea to leave 15–20% of your boot volume UNUSED. While running, Mac OS X and many apps temporarily “park” code that would otherwise use up your finite RAM. They treat this hard drive space as RAM, albeit slooooooow RAM.

Many programs, like Photoshop, use free drive space as a “scratch disk.” That’s how you are able to work on a 4GB image file in Photoshop when you have only 2GB of RAM installed!

Viewed in Activity Monitor, an app or process that is using >50% of the CPU should be suspect. (Although some monolithic programs do, and it’s normal.)

If you don’t need anything to be saved or “remembered” by an app, you can Force Quit it in Activity Monitor (the red octagonal stop sign shaped button – but it’s tricky when you try to highlight an app or process that’s hopping all over the place at a fraction of a second!).

I’ve done this before and then relaunched the app to find that it went from 54% CPU usage before to 9% after. So, beforehand the app ran and didn’t crash, but a portion of its code might have gotten caught in an infinite loop or something. Quitting and relaunching should fix this.

CLEANING OUT THE ATTIC (AND THE CELLAR) Even post-Mac OS Classic, a good old fashioned Mac shutdown (not just a restart) can really do wonders. If you select Shut Down from the menu bar and when everything disappears except for the wallpaper, you see the spinner spinning for a while, this is good! Mac OS X is doing some housekeeping, and maybe saving your system configuration, accounting for any and all internal modifications, external devices (hard drives, printers, scanners, third party keyboards, mice, Wacom tablets, etc.) and how they’re connected; USB, FireWire, eSATA PCI card, Bluetooth, Wi-Fi, etc., creating a cache of Extensions and Kernels it needs to load so it doesn’t have to go “fishing” at every startup, updating the bootcacheplaylist, the file system journal, and more.

After shutdown is complete, wait for all internal and external drives to stop spinning and turn off (SILENCE!)

Then hold down the shift key while you press the computer’s power on button. Don’t let go of the shift key. The Mac will take a little longer to start up than normally, but keep the shift key pressed until you see the Apple logo AND see the spinner start to spin. NOW you can release the shift key.

If you do not have Mac OS X set to “Automatic Login,” you will eventually be presented with the login window with the words “Safe Boot” appearing in red above the account names.

WAIT! Don’t log in just yet!

You see, all Apple will tell you about “Safe Mode” is that it is a troubleshooting method for when your Mac is all flaky in “full boot” mode.

Apple says Safe Mode does not load any third-party extensions (and even some of Apple’s own), nor does it load any Startup Items you have chosen in System Preferences—>Accounts, nor most Menu Bar items.

This is all true, but I came to learn that “Safe Boot” does all kinds of behind-the-scenes repairing and checking and fixing and maintaining and lots of other “Good Stuff.”

(But after years searching, no one has been able to tell me exactly what. They say, “Trust me. It’s doing Good Stuff.)

I know it ignores the kernelextension cache, forcing the OS to look for and load the essential kernel extensions anew. (If you’re still at the login screen, it even checks and repairs the BOOT VOLUME, something Disk Utility or any third-party disk utility can’t and refuses to do.)

Under “Safe Boot,” when at the login screen, only minimal parts of OS X have been loaded at that point, so Apple’s Safe Boot “utility chores” do their work in a basic environment free of hundreds of OS files that get loaded after you log in.

In Safe Boot, I leave it alone at the login screen for 10 minutes or so. I figured out that work was in progress before you log in when I noticed my external drives’ activity indicators showed lots of disk activity.

The drive indicators stop after 10 minutes or less.

THEN I log in. AND THEN, I don’t touch a thing (not even the keyboard or mouse), as that helpful Good Stuff runs for a few minutes AFTER login, and I don’t want to launch programs or even use the keyboard or mouse. I want Safe Boot to be able to perform its duties interference-free.

I go get a cup of coffee or launch App Store on my iPad to check for updates to my apps (something I do even more often than I check macupdate.com on my Mac for new shareware that appears at the top of the day’s list every 15 minutes or so!), and I begin actually using the Mac ten or so minutes after logging in.

I usually run some things that alter some of the files in Mac OS X in some way. I launch System Preferences, temporarily change the Energy Saver settings; I disconnect from the Internet and then reconnect; I click “Renew DHCP lease; I launch TextEdit, type some gobbledygook, wait for Autosave to auto save it, then save it myself; I launch Safari and maybe bookmark something; I launch Directory Utility and then quit it; Same for Network Utility, etc.

Then I SHUTDOWN my Mac as opposed to a restart, because shutdown updates some cache files, the bootcacheplaylist and does other things a restart does not. And if the spinner appears and takes a while before my Mac finally shuts down, that’s a Good Thing! IDK, but it could be overwriting corrupt preference files with fresh, clean ones and more.

You can always go into the Cache folder in System–>Library and trash some cache files (very recent ones – one’s with old dates should probably be left alone). It will only create replacements for these deleted cache files that will be new and clean and up-to-date. You can do the same to cache files with recent dates in Library–>Caches in your home folder. Again, it will only write fresh ones.

Even when my Mac is behaving itself, I boot into Safe Mode every two weeks or so.

Also, you can always hold down Command-s and hit the Mac’s power button. Don’t let go of Command-s until you see an old school, DOS-looking screen. Let go of the keys at this point. Mac OS X’s kernel is all that’s loaded at this point, plus some very minimal BSD Unix resources. But “Mac OS X” is hardly loaded at this point. The GUI hasn’t even loaded.

When entering this mode, it will print some abridged startup process information, then leave you at a Command Line prompt with a flashing cursor.

Type “/sbin/fsck[space]-fy[Return].” It should look like /sbin/fsck -fy before you press Return. It will do a verify/repair like Disk Utility does, except on your BOOT volume.

If it finishes and says everything’s A-OK, but prints “#FILE SYSTEM HAS BEEN MODIFIED” at the end, run the same command again, and again if necessary until it doesn’t print the “#FILE SYSTEM HAS BEEN MODIFIED” message anymore. Then you can enter “exit” at the command line to continue startup or enter “shutdown” if you’d rather shutdown and startup instead.

There is a great utility called AppleJack http://www.macupdate.com/app/mac/15667/applejack that is a Unix command line utility app that only runs in this textual Single User Mode (it has no GUI.)

Read AppleJack’s documentation especially how (all-caps) “AUTO” should be used with great care.

There is also much controversy about Repairing Permissions. Some say it’s a good thing to do; some say it’s not, and that apps change original file permission settings all the time, and it’s not necessarily a bad thing or abnormal.

Finally, indispensable tools in my utility “Tool Box” include the free shareware “Onyx” utility http://www.macupdate.com/app/mac/11582/onyx, TechTool Pro 6, Drive Genius 3, the venerable DiskWarrior 4 and Data Rescue 3 (and maybe Data Rescue PC if you’ve installed Windows on your Mac via Bootcamp).

Just two of TechTool’s many features are the ability to create a small partition on your boot drive (or any drive) that creates an Emergency Disk you can boot into if your boot drive needs repair. (Most utilities will not or cannot repair the startup drive. TechTool’s Emergency disk partition solves this.)

Second, TechTool lets you choose to install a preference pane that does a periodic drive S.M.A.R.T. check, backs up your precious Disk Directory (on any drive). If the Disk Directory gets erased or is too corrupt for DiskWarrior to repair, you’re screwed – except for maybe a Mac OS X “Archive and Install.”

The Disk Directory is a HUUUUUUUUGE file, so backing it up takes a lot of time and space. I have it set so that the Directory backups of all my drives are stored in separate folders on a drive I use for long-term data storage (archived photos, old documents I need to keep, old tax documents I need to hang onto for 7 years, etc.). I also set it to do this backup after beddy-bye time.

Fortunately, this TechTool preference pane in totally customizable for each task it performs. You can perform Directory backups once a week or once an hour, you can set it to perform a S.M.A.R.T. check every day or every hour. You can tell it to alert you and/or email you if a S.M.A.R.T check fails.

Most useful (to me) is that you can set a threshold for how much space on your hard drive you want to leave free (for the aforementioned reasons), like 15%, 20%, and have TechTool alert you when you’re approaching the threshold you’ve customized.

Then it’s time to archive some files you need to hang on to, but don’t access frequently, transferring them off your main drive.

P.S. Use an automatic backup utility and make sure Journaling is turned ON for all drives. (You can check, as well as turn it on for each drive in Disk Utility.)