Multimesh has terrible performance with high instance count

Godot Version

4.7.2.stable

Question

What am I doing wrong with multimesh for it to have horrid performance?
A scene with a terrain produced by the following code, no matter what I do (turn off directional shadow, GI, SSAO, fog, my custom shader) it has a frametime of 50ms with my 3080 Ti @ 1080p resolution. Its all coming from the opaque render pass.

Now I am aware ArrayMesh is more suited for my use case (also ignore that it produces cubes, it is only for testing, I will be making smooth/non cube terrain), and I have made ArrayMesh terrain before in much larger scale than this, but if possible I want to use multimesh because it has some benefits. (Such as easier per instance editing without having to remesh the entire chunk).

My guess is that since this isnt rasterization/triangle count related, the sheer amount of different transforms might be saturating the VRAM bandwidth? Or I am doing something fundamentally wrong.

If there is any other info needed I am happy to provide them, my project is also open source you can view the entirety of it here: GitHub - Caspianlake/SandboxGame · GitHub

extends Node3D

@export var world_size: int = 32
@export var grid_size: int = 32
@export var new_noise: FastNoiseLite = FastNoiseLite.new()

func _ready():
	var t3d: Transform3D = Transform3D(Basis(), Vector3(0, -700, 0))
	var main_mesh: BoxMesh = BoxMesh.new()
	main_mesh.size = Vector3(1,512,1)
	main_mesh.surface_set_material(0,load("res://Resources/UniversalMaterial.tres"))
	
	for cX in range(0,world_size):
		for cZ in range(0,world_size):
			var new_multimesh = MultiMesh.new()
			new_multimesh.transform_format = MultiMesh.TRANSFORM_3D
			new_multimesh.mesh = main_mesh
			new_multimesh.use_colors = true
			new_multimesh.instance_count = grid_size * grid_size
			new_multimesh.visible_instance_count = grid_size * grid_size
			
			var fX = cX * grid_size
			var fZ = cZ * grid_size
			
			for x in range(0,grid_size):
				for z in range(0, grid_size):
					var height = floorf(remap(new_noise.get_noise_2d(fX + x,fZ + z),-1.0,1.0,1.0,512.0))
					new_multimesh.set_instance_transform(x*grid_size + z, t3d)
			
			var mmi = MultiMeshInstance3D.new()
			mmi.multimesh = new_multimesh
			add_child(mmi)

Do you need as many as 1024 multimesh nodes?
What’s the opaque pass time on gpu and cpu side?

No matter what combination I try (1 node vs 1024) its the same, less or around 1 ms on CPU side, 50ms on GPU

Can you make a minimal scene that reproduces it?

A user in reddit helped me solve the problem. It was overdraw. (The meshes overlapping)