Look-ahead is a way for the encoder to basically buffer a number of frames, then determine which frames will need more compression based on the complexity it will need to bring down to the target bitrate.
Psycho Visual Tuning is a way to prioritize quality on portions of the video that is more apparent to us humans, by giving less data to sections that our brains have an easier time as being "good enough" at lower quality.
Code:
13:29:23.316: [rtmp stream: 'adv_stream'] User stopped the stream
13:29:23.316: Output 'adv_stream': stopping
13:29:23.316: Output 'adv_stream': Total frames output: 5484
13:29:23.316: Output 'adv_stream': Total drawn frames: 5001 (5524 attempted)
13:29:23.316: Output 'adv_stream': Number of lagged frames due to rendering lag/stalls: 523 (9.5%)
13:29:23.316: ==== Streaming Stop ================================================
13:29:23.361: warning: 2 frames left in the queue on closing
13:30:00.527: Output 'Replay Buffer': stopping
13:30:00.527: Output 'Replay Buffer': Total frames output: 22490
13:30:00.527: Output 'Replay Buffer': Total drawn frames: 21983 (22512 attempted)
13:30:00.527: Output 'Replay Buffer': Number of lagged frames due to rendering lag/stalls: 529 (2.3%)
13:30:00.527: ==== Replay Buffer Stop ============================================
13:30:00.791: Video stopped, number of skipped frames due to encoding lag: 774/28015 (2.8%)
Ok. Step 1 is fixed -- encoding lag is gone. The 2.8% shown for the recording section is actually a side-effect of the (new) NVenc encoder, where rendering lag is included in that count for whatever reason.
Now what's left is rendering lag. This is caused by OBS not being given enough GPU resources to perform the necessary scene composition within the timing window (for 60fps video, this needs to happen within 16.6ms). You can see this in real-time by opening the stats window -- it will show you the rendering lag numbers, as well as any frames that have been missed due to the timing. This is a problem usually when your game is using >80% of your GPU, and is ultimately a result of windows not giving OBS #1 priority regardless of anything else going on (if anything, it's usually given a lower priority than your game).
In OBS 24.0.3, there's a new "beta" workaround -- this may or may not work, but it's the best solution when it does. With Game Mode On (which you already have), run OBS in administrator mode (right-click on the obs64.exe or the shortcut to it, and select "Run as administrator"). This will put OBS on windows' GPU prioritization, allowing it to hopefully get the necessary GPU resources it needs alongside your game, meaning you can run your game at your normal settings and everything just works.
If that doesn't work, then you'll need to reduce your game settings to drop your GPU usage. Usually this can be achieved by limiting your framerate (either by setting a max framerate, or by using Vsync), and lowering your in-game graphics settings to the point where OBS has enough room to breathe.