You revise until you're happy. Or sick of it.
You give it to your beta readers - 1, 3, 9, however many. Get their comments back, pass out. Work up a way to address those things you like/do not like. Alcohol is optional.
You give it to your agent. Who reads and thinks and ponders and thinks and gets you notes back. You work up a way to address those things. Give it back, rinse/repeat until they are happy.
You go out on sub. Finally! Getting yesses, getting hms, getting no ways, getting a peculiar thing called a "no contract-exclusive revision" request. (Which is happening more and more nowadays, I hear). You think and talk with your agent: is this it? Should we revise for this publisher? Your agent should know the places they are subbing to and be able to give you a good indication of whether you should. But normally, most writers are gonna revise. 'Cause it's a step closer, man!
You revise. Hoo-ah! But whoops, not all of it is straight. (I've read some stories on the internet of writers doing 4-5 passes on a MS BEFORE acquisitions lately. Um, yikes!) So you go back to the board with those things they want changed and you change them.
Beta. Agent. Rinse and repeat.
You give it to the pub. Now you've got a 50/50 chance. Do they take it? It could all very well have been in vain - remember, they've got no contract, you've got no yes, so it's all on their side. You've done everything you can possibly do for this book.
But was it enough? Is that enough for you?
Now I want to ask you something: where would you have stopped? Where are you stopped right now? Would you go this far? Would you continuously edit your beloved MS for agent after agent, or would you say "eh, let's try with the next MS" and go from there?
Because if I know one thing, the thing I know is the writer that is published is the writer that didn't give up.
And I'd love to know where you're at with your determination.
Chin up! And report!