I'd take 5 rockstars supported by 1000 average devs. You need the rockstars to do some of the heavy algorithmic / visionary lifting and the 1000 people to make sure that the software is well tested, well documented, very well polished, etc. And also, you need the 5 rockstars to support the 1000 average devs by getting them past hurdles, etc. And you need a little bit of management in between to ensure the average guys aren't dissapointed by the salary differences, and the rockstars aren't frustrated by how long it takes to polish.
At Facebook it's probably worth it to get those few rockstars so they can make a drastic impact on the average guys. It's probably even worth it to give them $4 million a piece.
I'm not sure that the 1000 really will make sure the software is well tested, etc. Given that I haven't seen things on that scale, but the scales I have seen, the non-superstars don't seem to get why they should do any of that work or how to do it effectively. Maybe 5 rockstars and 30 very much above average. 1000 average won't get anything done and won't know what they have done.
For the less glamorous software tasks, you want to hire people who are in the B range (not outstanding, but notably above-average) for software talent but have an interest in advancing into project management or executive roles. Get a 25-year-old who's strong, but knows he's not going to be a CS luminary in 20 years, and who will look at tasks like documenting APIs as a learning experience and a way to get a sense of the company as a whole.
At Facebook it's probably worth it to get those few rockstars so they can make a drastic impact on the average guys. It's probably even worth it to give them $4 million a piece.