Most people define "optimal" in this context as the fastest way to build up funds and hit FIRE. There are all sorts of optimizations, but a rough summary of the biggest levers would be:
Max PreTaxAccts → Max RothAccts →Remainder in Brokerage
I did not do this. Most of my career I contributed 15% to my retirement accounts – initially to pre-tax 401k. Halfway through my career, they introduced the "Roth" 401k option. For me, I wanted to optimize for financial flexibility in retirement, so I switched all my contributions to the Roth (and this continued until I retired). From a financial accumulation perspective, this is the opposite of what you should do (Optimal would be to contribute to the Roth early in your career when wages are lower, and as you get into perhaps the 22% bracket, switch to traditional pre-tax for the rest of your career. That would give you optimal taxes and also flexibility.) I retired at age 56 with everything in my 401k (traditional + roth). Since my contributions never exceeded the max, my brokerage account was just a fraction of my total accumulation.
If I maxed out every year, I absolutely could have retired earlier. Would I do that differently if I started over? Perhaps. It's not clear to me. I believe we struck a good balance between living and saving.
Given the same circumstances, would I follow the "optimal" route of NOT switching to a Roth at the latter half of my career? Absolutely not – because my optimization was for later flexibility. If a Roth had be available at the start of my career, I definitely would have used this early and then switched to traditional later.
Now that I'm in deaccumulation, I'm really glad I wasn't "optimal" in my tax/accumulation strategy because having a nice mix of pre vs post tax funds allows me to engineer my taxable income each year to meet whatever goal I'm going after (ACA, Roth-Conversions, etc).
So, as many have already stated, it depends on how you define "optimal" in your view.