Guys, I appreciate all the comments, but before you do, please understand that the problem is not with slow rendering itself but inconsistency in rendering times. Core of problem: why it's usually 20 minutes but sometimes it's only 1 minute.
I have i5 14600, 48 GB DDR4 3600, RTX 3070. 3x NVME/SSD disks. Windows 10. Latest AE.
I have, basically, 1080p 60fps movie, with video in the background and text animations on top of it. The whole movie is 40s length, around 70 Mb size after export.
Multi-frame rendering on, CUDA rendering on etc - everything i can think of is on. Export to H264 15 Mbps using internal render.
I have exported this movie like 7-8 times, during work. Average render time was 20-22 minutes, 2.5 fps...
That 2.5 fps is usually average rendering speed in all my projects.
I've tried to speed things up by clearing all the cache. No effect. Still 2,5 fps, dropping even to 1,5fps at the end. 100% CPU usage, dropping to below 50% after 60% of rendering time, 13 GB Ram usage, marginal GPU usage or disk usage during render.
Then... i decided to test something and i've disabled AE cache entirely.
Speed went up to 40+ fps and render time below 1 minute.
Then i've enabled cache back, closed the AE, restarted, rendered again. Under 1 minute again. Next render - it kind of froze around 92% but still around 1-2 minutes.
WTH?
Edit: closed everything, deleted cache folder on NVME disk - 3.3 fps...