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

Consolidate benchmarks and use functions rather than scenes as the base unit #22

Merged
merged 3 commits into from
Mar 27, 2023
Merged

Consolidate benchmarks and use functions rather than scenes as the base unit #22

merged 3 commits into from
Mar 27, 2023

Conversation

myaaaaaaaaa
Copy link
Contributor

@myaaaaaaaaa myaaaaaaaaa commented Dec 7, 2022

GDScripts are now used as categories rather than directories, and functions are now the basic benchmarking unit rather than scenes. This allows nearly 40 files to be consolidated into 3 GDScripts, and makes it much easier to write new benchmarks since contributors only need to add a single script.

On startup, the loader now scans benchmarks/ for GDScripts, opens them up, and scans those for functions that begin with benchmark_ for automatic registration.

Instead of the time_limit mechanism, the benchmark_() functions return a Node to be added to the scene, which if null will signal to the manager that there is no time limit. This is admittedly a bit hacky, but it was the easiest way to do this consolidation while minimizing the amount of refactoring needed.

@myaaaaaaaaa
Copy link
Contributor Author

Hello, are there any questions or concerns with this proposed format that I should address before it can be merged?

@Calinou
Copy link
Member

Calinou commented Dec 20, 2022

Hello, are there any questions or concerns with this proposed format that I should address before it can be merged?

I've been busy lately and haven't had time to review pull requests. Holiday season is also starting, so it will take a few weeks until I can get to this and give it enough time for a proper review.

Rest assured, your work is very appreciated 🙂

@myaaaaaaaaa
Copy link
Contributor Author

I've been busy lately and haven't had time to review pull requests. Holiday season is also starting, so it will take a few weeks until I can get to this and give it enough time for a proper review.

Okay, thank you for the update. Happy holidays!

@myaaaaaaaaa myaaaaaaaaa mentioned this pull request Feb 8, 2023
@Calinou
Copy link
Member

Calinou commented Mar 24, 2023

Benchmark results:

main

{
	"benchmarks": [
		{
			"category": "Gdscript",
			"name": "Packed String Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 1653
			}
		},
		{
			"category": "Gdscript",
			"name": "Typed Int Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 2538
			}
		},
		{
			"category": "Gdscript",
			"name": "Typed String Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 3652
			}
		},
		{
			"category": "Gdscript",
			"name": "Untyped Int Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 2565
			}
		},
		{
			"category": "Gdscript",
			"name": "Untyped String Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 3648
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Basic Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.56,
				"render_gpu": 0.57,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Directional Light Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.87,
				"render_gpu": 0.75,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Dynamic Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 3.12,
				"render_gpu": 0.55,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Dynamic Light Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.73,
				"render_gpu": 0.61,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Dynamic Light Cull With Shadows",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 1.59,
				"render_gpu": 0.64,
				"time": 5007
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Static Light Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.58,
				"render_gpu": 0.59,
				"time": 5003
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "1000 Polygon 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.18,
				"render_gpu": 0.03,
				"time": 5006
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "100 Polygon 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.04,
				"render_gpu": 0.02,
				"time": 5003
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "10 Polygon 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.02,
				"render_gpu": 0.02,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Sprite 2d",
			"name": "5000 Sprite 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.36,
				"render_gpu": 0.31,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Sprite 2d",
			"name": "500 Sprite 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.06,
				"render_gpu": 0.05,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Sprite 2d",
			"name": "50 Sprite 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.03,
				"render_gpu": 0.03,
				"time": 5006
			}
		}
	],
	"engine": {
		"binary_size": 115410976,
		"build_type": "editor",
		"version": "v4.0.stable.official",
		"version_hash": "92bee43adba8d2401ef40e2480e53087bcb1eaf1"
	},
	"system": {
		"cpu_architecture": "x86_64",
		"cpu_count": 32,
		"cpu_name": "13th Gen Intel(R) Core(TM) i9-13900K",
		"gpu_name": "NVIDIA GeForce RTX 4090",
		"gpu_vendor": "NVIDIA",
		"os": "Linux"
	}
}

This PR

{
	"benchmarks": [
		{
			"category": "Gdscript > Array",
			"name": "Packed String Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 1652
			}
		},
		{
			"category": "Gdscript > Array",
			"name": "Typed Int Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 2705
			}
		},
		{
			"category": "Gdscript > Array",
			"name": "Typed String Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 3668
			}
		},
		{
			"category": "Gdscript > Array",
			"name": "Untyped Int Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 2485
			}
		},
		{
			"category": "Gdscript > Array",
			"name": "Untyped String Array",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0,
				"render_gpu": 0,
				"time": 3651
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Basic Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.84,
				"render_gpu": 0.57,
				"time": 5004
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Directional Light Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 2.22,
				"render_gpu": 0.79,
				"time": 5007
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Dynamic Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 4.44,
				"render_gpu": 0.58,
				"time": 5002
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Dynamic Light Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 2.08,
				"render_gpu": 0.61,
				"time": 5002
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Dynamic Light Cull With Shadows",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 2.9,
				"render_gpu": 0.63,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Culling",
			"name": "Static Light Cull",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 1.89,
				"render_gpu": 0.6,
				"time": 5006
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "1000 Polygon 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.16,
				"render_gpu": 0.03,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "100 Polygon 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.03,
				"render_gpu": 0.02,
				"time": 5007
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "10 Polygon 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.02,
				"render_gpu": 0.02,
				"time": 5005
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "5000 Sprite 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.35,
				"render_gpu": 0.3,
				"time": 5000
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "500 Sprite 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.05,
				"render_gpu": 0.05,
				"time": 5008
			}
		},
		{
			"category": "Rendering > Polygon 2d",
			"name": "50 Sprite 2d",
			"results": {
				"idle": 0,
				"physics": 0,
				"render_cpu": 0.02,
				"render_gpu": 0.03,
				"time": 5008
			}
		}
	],
	"engine": {
		"binary_size": 115410976,
		"build_type": "editor",
		"version": "v4.0.stable.official",
		"version_hash": "92bee43adba8d2401ef40e2480e53087bcb1eaf1"
	},
	"system": {
		"cpu_architecture": "x86_64",
		"cpu_count": 32,
		"cpu_name": "13th Gen Intel(R) Core(TM) i9-13900K",
		"gpu_name": "NVIDIA GeForce RTX 4090",
		"gpu_vendor": "NVIDIA",
		"os": "Linux"
	}
}

Results are mostly similar, but render_cpu is much higher with this PR for 3D benchmarks (both runs were made with 4.0.stable official binaries). Can you reproduce this locally?

@myaaaaaaaaa
Copy link
Contributor Author

This may be due to shader compilation, I'm observing a similar render_cpu difference from running the main branch twice. Can you still reproduce this even after doing a warm-up run?

manager.gd currently skips a few frames before each benchmark in an attempt to avoid this, but apparently this isn't enough.

FYI, you can use diff --color -u5 <(cat a.json | jq .) <(cat b.json | jq .) (requires jq) for an easier time comparing results 🙂

@Calinou
Copy link
Member

Calinou commented Mar 25, 2023

This may be due to shader compilation, I'm observing a similar render_cpu difference from running the main branch twice. Can you still reproduce this even after doing a warm-up run?

CPU time is much lower on a second run in 3D benchmarks, which indicates an issue with shader compilation times being counted in CPU time.

Edit: Issue opened: #29

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Calinou Calinou merged commit 0c56e6b into godotengine:main Mar 27, 2023
@myaaaaaaaaa myaaaaaaaaa deleted the sub-benchmarks branch March 27, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants