Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extreme slowdowns when freeing and reallocating many nodes that share the same Mesh #69874

Closed
myaaaaaaaaa opened this issue Dec 10, 2022 · 0 comments · Fixed by #72421
Closed

Comments

@myaaaaaaaaa
Copy link
Contributor

myaaaaaaaaa commented Dec 10, 2022

Godot version

v4.0.beta8.official.45cac42c0

System information

Linux, Vulkan API 1.3.224 - Using Vulkan Device #0: Intel - Intel(R) Iris(R) Plus Graphics 655 (CFL GT3)

Issue description

The following sample code builds a tree of nodes that share the same ArrayMesh. Freeing and then reallocating this tree causes extreme slowdowns.

extends Benchmark

func build_node() -> Node3D:
	var mesh := ArrayMesh.new()
	var rt := MeshInstance3D.new()
	for i in 10_000:
		var n := MeshInstance3D.new()

		####################
		### Removing this line stops the slowdown
		n.mesh = mesh

		rt.add_child(n)
	return rt

####################
### 200 milliseconds
func benchmark_alloc_free_1():
	build_node().free()

####################
### 14 seconds (70x slower)
func benchmark_alloc_free_5():
	for i in 5:
		build_node().free()

Steps to reproduce

Clone the below PR and run the HLOD setup benchmark from the root directory via:
godot-4.0beta8-binary-name -- --run-benchmarks --include-benchmarks=rendering/hlod/setup

Minimal reproduction project

godotengine/godot-benchmarks#23

@Calinou Calinou added this to the 4.0 milestone Dec 10, 2022
@myaaaaaaaaa myaaaaaaaaa changed the title Godot freezes after reloading scenes with many deeply nested nodes Extremely inconsistent memory allocator behavior when allocating and freeing deeply nested nodes Dec 15, 2022
@myaaaaaaaaa myaaaaaaaaa changed the title Extremely inconsistent memory allocator behavior when allocating and freeing deeply nested nodes Extremely inconsistent memory allocator behavior when allocating deeply nested nodes Dec 15, 2022
@myaaaaaaaaa myaaaaaaaaa changed the title Extremely inconsistent memory allocator behavior when allocating deeply nested nodes Extremely inconsistent memory allocator behavior when allocating and freeing deeply nested nodes Dec 15, 2022
@myaaaaaaaaa myaaaaaaaaa changed the title Extremely inconsistent memory allocator behavior when allocating and freeing deeply nested nodes Extremely inconsistent memory allocator behavior when freeing and reallocating many nodes that share the same ArrayMesh Jan 28, 2023
@myaaaaaaaaa myaaaaaaaaa changed the title Extremely inconsistent memory allocator behavior when freeing and reallocating many nodes that share the same ArrayMesh Extreme slowdowns when freeing and reallocating many nodes that share the same Mesh Jan 28, 2023
@vnen vnen modified the milestones: 4.0, 4.1 Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants