We've all seen it... the multi-colored, spinning pinwheel icon that tells us that something is wrong. Technically, it tells us when an application has either completely hung on us (unresponsive), or is taking longer to do something than the system thinks it should take. Regardless, it's never a good sign. We typically see this on older Macs that are trying to run new software with old hardware (pushing the limits), but we even see it on newer Macs.
In the case of older hardware, there may not be a lot we can do (except for upgrade RAM or maybe upgrade to an SSD). With newer hardware, however, there are a few tricks up my sleeve for minimizing the time we spend watching that mesmerizing ball of death.
Keep your software current
This is one of the easiest things you can do, and is hugely beneficial. Software is designed to be constantly updated. Not only do software updates usually give you new features, but they almost always include bug fixes and performance enhancements. These enhancements benefit you directly by generally speeding things up. I recommend checking for updates on all your software (system-wide, not just your Operating System) about once a week. In some cases, this can be done via the Mac App Store or within the apps themselves (most apps have a mechanism to check for updates automatically when you open the app). If it shows there's an update, grab it!
Repair DIsk Permissions (Disk Utility)
While UNIX (which is at the heart of what makes OS X so great) is a great solid, secure Operating System, it's not without its imperfections. The more disk I/O (input/output) you have, the more likly you are to have file permission inconsistencies. This is not only applicable when installing and removing software, but every day file and application access. As files are used (constantly, in some cases), you increase the chance that certain permissions related to those files are modified, and in turn, don't match what they should be. This usually results in applications quitting unexpectedly, acting funny or running slow (which has a tendency to result in a "beach ball of death"). To avoid this, Apple has provided a utility to re-align those file permissions. I recommend running this about once a month or so (heavy users may want to run it more often).
To run this utility, open Disk Utility (Applications > Utilities). On the left side of the screen, highlight the partition you want to fix (usually called "Macintosh HD"), then click "Repair Disk Permissions". This will do two things: 1) it will check the state of file permissions on your files and 2) correct any problems that it finds. If you want to get creative, try creating an Automator action/application, then set that in your Calendar app, scheduling it to run automatically once a month.
Note: if you run "Repair Disk Permissions" and it finds a significant number of files to fix, you ay want to run it a second or third time to catch everything. It's rare that it doesn't find anything so don't be surprised.
Boot in Safe Mode
In some cases, keeping software current and repairing disk permissions won't help because the problem goes deeper than that. I've had cases in the past where my system has been rendered useless because an app goes completely haywire. Just the other day, actually, my Evernote prevented me from using my system. I'm still unsure why or how, but I at least found the problem. In my case, I have my Mac user account set to automatically run Evernote upon login (you can do this with any application by going into System Preferences > Accounts and clicking on the Login Items tab). The problem in my case was that because I had it set to automatically launch on login, I couldn't login without my system hanging on me... every single time.
To get around this, I booted in safe Mode. Safe Mode allows you to run the Operating System with minimal software and drivers loaded automatically... only the bare essentials will run (no 3rd-party apps, only basic hardware drivers, etc). This is a great tool for diagnosing issues similar to the one I had.
To boot into Safe Mode, turn your computer off for 10 seconds. Turn the computer back on. As soon as you hear the "bong" system sound, press and hold the Shift key. That's it. In my case, I logged in under Safe Mode, entered System Preferences, disabled all my automatic app launch options, then re-enabled them one at a time to discover what was causing the issue.