I've written this up a couple times in the past, but it's worth doing again.
A few years back, a gun magazine writer decided to address the question of velocity and barrel length. In order to keep it allapples to apples, he started with a single .30 caliber rifle with a 26-inch barrel, and lopped it off in one-inch increments with several small lots of handloaded ammunition. Same bullet, same primers, and same cases. Only the powders changed. He used a near maximum listed charge from one loading manual for each powder. The powders were chosen by burn rate, and the powders used were all taken from the list of acceptable powders for the caliber.
He discovered that one of the faster powders in the group didn't follow the old "Longer barrels give higher velocities" rule once a certain barrel length was passed. If memory serves me, it were IMR 3031. Top speed was reached at 23 inches of barrel, and there was very little difference at 22 inches. At 24 inches, the velocity was actually a bit less than it was at 23 inches...and less again at 25 and 26 inches, though the difference from 24-26 was negligible.