This was my favorite reply to the question. Music theory is great, and it really can be helpful with composition. But I've also found that what I'm
really looking for when trying to
improvise, or perform, is having studied and worked on the theory - specifically on the ear training and the process of connecting that to my fingers - to the point where I don't have to think about it any more.
The composition vs performance framing is very useful I think. Some musicians might just want to do composition, and can spend a little more time between the notes figuring out what ought to come next. (Although even in this case, it's easy to get bogged down in analysis and forget about what feels right). But a lot of musicians want to be able to improvise - and the difference is like being able to write down a compelling argument vs being able to make a compelling "speech" off the cuff.
Yeah, in both cases, you're going to need a good understanding of grammar and vocabulary - but when you're trying to make that speech (or improvise a solo), you're just not going to have the time to think about "the sound I want to hear next is the sound of the 5th of the chord the band is implying." All our practice and theory homework is in service of the fingers just doing what's in our heads automatically - and sometimes, even surprising ourselves with what comes out.