Optifine is honorable legacy, so it's understandable that it doesn't work as robust as before. (try to support graphics enhancement mod for 9.5 years despite all mojang shenanigans)
A Java game made 10 years ago that still lags on modern hardware is unoptimised? Perish the thought...