Render from command line taking significantly longer (sometimes) in Blender 4.1

From past experience I usually find rendering is a bit quicker via the command line, but with blender 4.1 there appears to be an issue some times.
Around half the time I try to render a complex scene from the command line it’ll run extremely slowly, stdout is currently reporting a single 1920x1080 still will take over 2 hours to complete with GPU support.
And then I quit, run the same command and to render it only takes 3 minutes.

blender rooms.blend -b --python scripts\export_stills.py -- --cycles-device OPTIX
import bpy
room = bpy.data.scenes["room.001"]
bpy.context.window.scene = room
room.render.resolution_percentage = 100
room.render.resolution_x = 1920
room.render.resolution_y = 1080
room.render.engine = "CYCLES"
room.cycles.device = "GPU"
room.cycles.samples = 2048
room.cycles.adaptive_threshold = 0.01
room.cycles.use_denoising = True
room.cycles.denoiser = "OPENIMAGEDENOISE"
room.cycles.denoising_input_passes = "RGB_ALBEDO_NORMAL"
room.cycles.denoising_prefilter = "ACCURATE"
room.cycles.denoising_use_gpu = False
bpy.ops.render.render(write_still=True)

The same command renders at full speed every time if I run blender’s GUI.

Seems like a bug, has anyone else noticed this and is there a sure fire way to prevent it getting stuck?