As somebody who's about to finish a CS dissertation, I sometimes think the best way to do CS research is to get a somewhat interesting software engineering job that allows for a 4-day week and to do research as a side project. Most likely, this gives one more research time than staying in academia (with the exception of the first Post Doc, perhaps).
Edit: This works for most of CS, but not for most of Physics, I assume.