I never had problems with devices becoming slow where a factory reset does not help, this sounds odd since a factory reset clears all configuration data. I tend to install some AOSP-derived distribution on devices which are supported (or which I port it to myself), for those for which I can not find a working distribution I pare down the factory distribution as much as I can by removing bloat and replacing obnoxious apps with functional ones from F-Droid. This makes it possible to use e.g. a Samsung Galaxy SIII from 2014 with Android 11 as a daily device for 'dangerous' work.