I live in SV and am in my early 40s and can only comment on what I've seen firsthand or heard about secondhand. Based on that, I don't really see ageism. I work with people in their 20s, and I work with people in their 60s. It can be harder to find a new job at comparable pay as you get older, but it has a lot more to do with the following:

(1) Salary expectations. Somebody works at the same company for 20 years, gets an annual raise that's above the rate of inflation, and has an expectation that if they go someplace else, they're going to get as much or more money.

This might happen, but it's not guaranteed. I've worked at companies in other industries where it was common for people to work at those companies for 30+ years, then retire. These companies have different notions as far as annual raises and how generous the perqs and bonuses should be, because they expect people to be around for a long time.

Tech companies tend to be a lot more generous, because there are much higher turnover rates and they have to work harder to retain talent. The result is that after 10 or 20 years at a tech company, you may become accustomed to getting paid above your market value (I hope to have that problem someday :). This isn't always the case, but it does happen.

(2) Lack of relevant technical minutiae. Everybody loves to say things like, "it doesn't matter what you know, it's your capacity to learn!" Or, "my knowledge of abstract CS concepts means I can pick up the technical minutiae associated with a learning a new language/library/platform/etc. in no time!" All of these things are true to an extent, and you're not going to get very far without them. However, none of them have anything to do with actually accomplishing anything- they're all just modifiers to your ability to learn and adapt, prior to accomplishing anything.

Unfortunately, accomplishing anything requires technical minutiae. Some of it is more widely applicable stuff like programming in a particular language or using certain tools, but the stuff that makes you really really valuable to your current employer is more likely to be the niche that you carve out for yourself over the years. This means, knowledge of specific codebases, and domain-specific knowledge, some of which might be from other disciplines like math or finance or electrical engineering. When you go someplace new, your niche knowledge is either going to be invaluable (yay!) or meaningless (bummer :( ). Most of the time, it's the latter. So, again, this is a case where through no fault of their own, someone has ended up getting paid a lot of money for doing a great job, by acquiring lots of valuable skills that don't mean much outside of that company and position.

(3) Burnout. Sometimes people just get sick of spending so much time around computers after 20 or 30 years (or 5-10!). They lose their enthusiasm and aren't as motivated to keep up to date. If you're burned out on your profession, you will have a harder time finding new work, for any number of reasons. It's unfortunate but it happens to everyone at some point or another, maybe many times throughout their career. Some people find ways to renew their interest and get out of this mindset, some don't. Older people are more susceptible to this because they have more important things in their lives (like family).

TLDR: don't get frustrated, try to see things from a prospective employer's point of view in addition to your own POV, and keep your skills sharp and up to date. Don't coast. Stay curious and make sure you're still having fun doing what you do. If you're no longer curious or no longer enjoy it, see if you can come at it from a different angle and rejuvenate your interest. If not, you'd probably be happier taking a left turn in your career anyway, doing something completely different.