Budget CPUs that performs well despite mitigations

When it comes to buying a budget system, how “old” can you go before CPU mitigations result in too big of a performance tax to be worth buying (I mean with the full mitigations)? I hear that with Intel, 10-12th gen seems to be the sweet spot (with 9th gen still suffering from massive performance dips). What about the Ryzen CPUs? Are Ryzen 5000s still good?