It entirely depends on how your mainsheet is rigged, this isn't something you ought to guess at. There are many possible "optimal" lengths depending on whether the mainsail is sheeted at the end, midboom, amount of leverage it's rigged with, etc.
I would suggest looking at your existing mainsheet with the boom out all the way and deciding if it's the right length, and adding or subtracting a little from that depending on how you feel about it. Or simulate a mainsheet with a length of thin nylon string run through the hardware.