This paper introduces the theoretical basis and optimization method of diesel engine working process theory. By comparing two Miller cycle schemes of B20 biodiesel under different load conditions of 1000 rpm (100%, 75%, and 50%), the best Miller cycle scheme and the best Miller degree were found. Then, based on the Miller cycle scheme, its performance was optimized and analyzed, and the best intake timing scheme of the B20 biodiesel engine under different working conditions was obtained. The results show that the performance of B20 biodiesel in variable valve overlap angle Miller cycle is better than that in variable cam profile Miller cycle, and the effect is the best when the Miller degree is 30 °CA. When B20 biodiesel is used under 100% and 50% load conditions, the maximum power under the two loads is in the area near intake valve timing 179 °CAA and exhaust valve timing 174 °CAA, and intake valve timing 224.5 °CAA and exhaust valve timing 119 °CAA, respectively. Fuel consumption, soot emissions, and NOx emissions also have the corresponding best performance intake valve and exhaust valve positions.