p.Chaos.Solver.IslandGroups.MinBodiesPerWorker
p.Chaos.Solver.IslandGroups.MinBodiesPerWorker
#Overview
name: p.Chaos.Solver.IslandGroups.MinBodiesPerWorker
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The minimum number of bodies we want per worker thread
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.IslandGroups.MinBodiesPerWorker is to set the minimum number of bodies that should be processed by each worker thread in the Chaos physics solver’s island system. This setting is part of the performance optimization mechanism for the Chaos physics engine in Unreal Engine 5.
This setting variable is primarily used by the Chaos physics subsystem, specifically within the island grouping functionality. The island system is a technique used in physics simulations to group interacting objects together for more efficient processing.
The value of this variable is set through the Unreal Engine’s console variable system. It’s initialized with a default value of 50 but can be changed at runtime using console commands or through configuration files.
The associated variable GIslandGroupsMinBodiesPerWorker directly interacts with this setting. They share the same value, with GIslandGroupsMinBodiesPerWorker being the actual variable used in the code, while p.Chaos.Solver.IslandGroups.MinBodiesPerWorker is the console-accessible name.
Developers should be aware that this variable affects the distribution of work among threads in the physics simulation. Setting it too low might result in too many small tasks, which could increase overhead on many-core systems. Setting it too high might lead to uneven work distribution and potentially reduced parallelism.
Best practices when using this variable include:
- Profiling the physics performance with different values to find the optimal setting for your specific game and target hardware.
- Considering the typical number of physics bodies in your scenes when adjusting this value.
- Balancing this setting with other related physics settings for optimal performance.
Regarding the associated variable GIslandGroupsMinBodiesPerWorker:
- Its purpose is identical to p.Chaos.Solver.IslandGroups.MinBodiesPerWorker, serving as the internal representation of the setting.
- It’s used directly in the Chaos physics code, specifically in the FPBDIslandGroupManager::BuildGroups function to ensure that each task has at least the specified minimum number of bodies.
- The value is set through the console variable system and can be modified at runtime.
- It interacts with CVars::GIslandGroupsMinConstraintsPerWorker to determine the final target number of bodies per task.
- Developers should be aware that changes to this variable will directly affect the physics simulation’s work distribution.
- Best practices include monitoring this variable alongside other physics performance metrics and adjusting it as part of overall physics optimization efforts.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandGroupManager.cpp:48
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// We want a minimum number of bodies to gather on each thread. This prevents us running too many tiny tasks on a many-core machine
int32 GIslandGroupsMinBodiesPerWorker = 50;
FAutoConsoleVariableRef GCVarIslandGroupsMinBodiesPerWorker(TEXT("p.Chaos.Solver.IslandGroups.MinBodiesPerWorker"), GIslandGroupsMinBodiesPerWorker, TEXT("The minimum number of bodies we want per worker thread"));
}
namespace Private
{
#Associated Variable and Callsites
This variable is associated with another variable named GIslandGroupsMinBodiesPerWorker
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandGroupManager.cpp:47
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// We want a minimum number of bodies to gather on each thread. This prevents us running too many tiny tasks on a many-core machine
int32 GIslandGroupsMinBodiesPerWorker = 50;
FAutoConsoleVariableRef GCVarIslandGroupsMinBodiesPerWorker(TEXT("p.Chaos.Solver.IslandGroups.MinBodiesPerWorker"), GIslandGroupsMinBodiesPerWorker, TEXT("The minimum number of bodies we want per worker thread"));
}
namespace Private
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandGroupManager.cpp:162
Scope (from outer to inner):
file
namespace Chaos
namespace Private
function int32 FPBDIslandGroupManager::BuildGroups
Source code excerpt:
// @todo(chaos): we may want to consider separating the gather task count from the number of island groups by adding a second multiplier.
TargetNumConstraintsPerTask = FMath::Max(TargetNumConstraintsPerTask, CVars::GIslandGroupsMinConstraintsPerWorker);
TargetNumBodiesPerTask = FMath::Max(TargetNumConstraintsPerTask, CVars::GIslandGroupsMinBodiesPerWorker);
// Reset all the groups
for (TUniquePtr<FPBDIslandConstraintGroupSolver>& IslandGroup : IslandGroups)
{
IslandGroup->Reset();
}