Keeping this in mind, SF proper has a natural and inherent economic rent. So there is only so much pressure more building could relieve in SF proper. That said, I don't think many people would have much issue with being able to afford a place in San Mateo, Mountain View or San Jose, even Fremont. The problem is the whole bay area is averse to build up. So the only current option for those not able to afford the housing, is to commute two hours each way --South from Gilroy, East from Livermore/Tracy, northeast Coco county, etc. or doubling, tripling up and sharing rent. But that's not an option for many families.
It'd be physically difficult to have more than 6 million people living in San Francisco, no matter what density we built. So there would be some limit, just not the current approximate 800 odd thousand. The solution is to have an integrated Bay Area plan to accommodate as many people as the area can support. We must also keep in mind the ecological impact of sustaining more people in a semi arid region so perhaps desalination plants to offset water demand. Most of all, a regional government capable of making hard decisions rather than one which gives in to boisterous interest groups (rent control, height & shade restrictions, prop 13, and the adversity to pubic transit.