To the author: You have thought about your boss likely 100x more than he ever thought about you.
Don't do him this favor. You are giving him too much power that way.
And be sure that he forgot about you, like COMPLETELY, maximum 72 hours after you were let go. Do the same. Take your lessons, internalize them, and forget the source. Be like an LLM: have the right conclusion inside your brain after the source material is long gone and thrown out.
Move on.
---
I am in my 40s and just now I am beginning to start understanding only a part of the dynamics involved in companies. But the TL;DR is that executives want to shine and look better, always. They only care about an ever-increasing compensation _and_ bonuses. They care not about the company's long-term success.
If you are in the way of that -- with your pesky technical stability and less resource usage, being one example -- then you are an inconvenience and will be removed. They want people who help them look better to their upper echelons.
That's just one example.
From here on my playbook will be to attend more executive meetings when I start a job, and get a feel of who does what and what are their goals -- and make sure I at least don't stand in the line of the fire when sh1t hits the fan. And will always have something else lined up even if I love my current team to bits. Simply because the said said team has exactly zero say if I get to stay or get booted out simply because somebody two levels above wants a promotion and my salary is making it look like they spend too much.
(I remember how much I regretted losing one job some three years ago. I loved everyone there but I had a terrible health condition and couldn't perform. But you know what? The guy who was practically doing 80% of everything there, all the time, got fired a year and half after me. Reason? Product is done and delivered, we don't need you anymore, nevermind that we get feature requests and the occasional bug reports all the time.)
"Nothing personal. Just business."
Well, two can play at that game. Wish me luck. I want my heart to harden. I want to stop caring. I want to learn to preserve my caring for the things that truly excite me about technology.
I might fail. But I am very quickly learning the game and I will adapt.
I wish OP does the same.