How to improve your Mac's performance

What can you do if your Mac randomly crashes or kernel panics?