Project

General

Profile

Bug #28634

Unnecessary GCAlloc and Increased CPU Time Building Terrain

Added by Gameslinx almost 2 years ago.

Status:
New
Severity:
Low
Assignee:
-
Category:
Bug Tracker
Target version:
-
Start date:
05/20/2022
% Done:

0%

Version:
Platform:
Linux, OSX, Windows
Expansion:
Breaking Ground, Core Game, Making History
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

When profiling the game when a terrain quad is being built, there is a significant amount of GC.Alloc (garbage) being created. The profiler does have a performance hit, but these allocations are taking up 19% of the quad building time. It can be easily avoided, reducing both garbage generated and CPU time.

When accessing Mesh.normals, a new copy of the normals array is returned. In one of the pictures I have attached, Mesh.normals is being accessed for every vertex in the PQS cache. This is the source of these GC.Alloc flags. To fix this, refer to the last image I have attached. In my proposed solution, only 1 copy of the array is created. When accessing that array, a new copy is not made. This will improve quad building times and reduce GC.Alloc flags significantly.

GCAlloc in profiler.png (120 KB) GCAlloc in profiler.png Screenshot of GCAlloc flags in profiler Gameslinx, 05/20/2022 06:38 PM
BuildTangents method with bad array calling.png (30.9 KB) BuildTangents method with bad array calling.png Screenshot of method causing this Gameslinx, 05/20/2022 06:38 PM
Fixed version.png (34.2 KB) Fixed version.png Proposed solution Gameslinx, 05/20/2022 06:38 PM
58899
58900
58901

Also available in: Atom PDF