p.Chaos.NewtonEvolution.MinParallelBatchSize
p.Chaos.NewtonEvolution.MinParallelBatchSize
#Overview
name: p.Chaos.NewtonEvolution.MinParallelBatchSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.NewtonEvolution.MinParallelBatchSize is to control the minimum batch size for parallel processing in the Newton Evolution system of Unreal Engine’s Chaos physics engine. This setting is used to optimize performance in multi-threaded environments.
-
This setting variable is primarily used by the Chaos physics engine, specifically in the Newton Evolution subsystem, which is part of Unreal Engine’s experimental Chaos module.
-
The value of this variable is set as a console variable (CVar) with an initial value of 300. It can be modified at runtime through console commands or programmatically.
-
This variable interacts closely with CVarChaosNewtonEvolutionParallelIntegrate. When parallel integration is enabled, MinParallelBatchSize determines the minimum number of items to process in each parallel batch.
-
Developers must be aware that this variable only takes effect when parallel integration is enabled (CVarChaosNewtonEvolutionParallelIntegrate is true). If parallel integration is disabled, the batch size is set to the maximum integer value, effectively disabling parallelization.
-
Best practices for using this variable include:
- Experimenting with different values to find the optimal balance between parallelization overhead and performance gains.
- Considering the target hardware when setting this value, as optimal batch sizes may vary depending on the number of available cores.
- Monitoring performance metrics to ensure that changes to this value are actually improving overall system performance.
Regarding the associated variable CVarChaosNewtonEvolutionMinParallelBatchSize:
-
This is the actual CVar object that stores and manages the MinParallelBatchSize value.
-
It’s defined as a TAutoConsoleVariable
, allowing it to be easily modified through the console or code. -
The variable is marked with ECVF_Cheat flag, indicating it’s intended for debugging or development use and should not be exposed to end-users in shipping builds.
-
When using this variable in code, developers should use the GetValueOnAnyThread() method to retrieve its current value, as seen in the provided code excerpt.
-
It’s important to note that changes to this variable will take effect immediately, potentially affecting ongoing physics simulations. Care should be taken when modifying it during runtime to avoid unexpected behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/NewtonEvolution.cpp:36
Scope: file
Source code excerpt:
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionFastPositionBasedFriction(TEXT("p.Chaos.NewtonEvolution.FastPositionBasedFriction"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionUseSmoothTimeStep(TEXT("p.Chaos.NewtonEvolution.UseSmoothTimeStep"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<int32> CVarChaosNewtonEvolutionMinParallelBatchSize(TEXT("p.Chaos.NewtonEvolution.MinParallelBatchSize"), 300, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionWriteCCDContacts(TEXT("p.Chaos.NewtonEvolution.WriteCCDContacts"), false, TEXT("Write CCD collision contacts and normals potentially causing the CCD collision threads to lock, allowing for debugging of these contacts."), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionParallelIntegrate(TEXT("p.Chaos.NewtonEvolution.ParalleIntegrate"), false, TEXT("Run the integration step in parallel for."), ECVF_Cheat);
//#if INTEL_ISPC && !UE_BUILD_SHIPPING
//bool bChaos_PostIterationUpdates_ISPC_Enabled = true;
//FAutoConsoleVariableRef CVarChaosPostIterationUpdatesISPCEnabled(TEXT("p.Chaos.PostIterationUpdates.ISPC"), bChaos_PostIterationUpdates_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in Newton Post iteration updates"));
#Associated Variable and Callsites
This variable is associated with another variable named CVarChaosNewtonEvolutionMinParallelBatchSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/NewtonEvolution.cpp:36
Scope: file
Source code excerpt:
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionFastPositionBasedFriction(TEXT("p.Chaos.NewtonEvolution.FastPositionBasedFriction"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionUseSmoothTimeStep(TEXT("p.Chaos.NewtonEvolution.UseSmoothTimeStep"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<int32> CVarChaosNewtonEvolutionMinParallelBatchSize(TEXT("p.Chaos.NewtonEvolution.MinParallelBatchSize"), 300, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionWriteCCDContacts(TEXT("p.Chaos.NewtonEvolution.WriteCCDContacts"), false, TEXT("Write CCD collision contacts and normals potentially causing the CCD collision threads to lock, allowing for debugging of these contacts."), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosNewtonEvolutionParallelIntegrate(TEXT("p.Chaos.NewtonEvolution.ParalleIntegrate"), false, TEXT("Run the integration step in parallel for."), ECVF_Cheat);
//#if INTEL_ISPC && !UE_BUILD_SHIPPING
//bool bChaos_PostIterationUpdates_ISPC_Enabled = true;
//FAutoConsoleVariableRef CVarChaosPostIterationUpdatesISPCEnabled(TEXT("p.Chaos.PostIterationUpdates.ISPC"), bChaos_PostIterationUpdates_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in Newton Post iteration updates"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/NewtonEvolution.cpp:704
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FNewtonEvolution::AdvanceOneTimeStep
Source code excerpt:
const int32 MinParallelBatchSize = !CVarChaosNewtonEvolutionParallelIntegrate.GetValueOnAnyThread() ?
TNumericLimits<int32>::Max() : // Disable
CVarChaosNewtonEvolutionMinParallelBatchSize.GetValueOnAnyThread(); // TODO: 1000 is a guess, tune this!
const bool bWriteCCDContacts = CVarChaosNewtonEvolutionWriteCCDContacts.GetValueOnAnyThread();
{
TRACE_CPUPROFILER_EVENT_SCOPE(ChaosNewtonPreIterationUpdates);
MParticlesActiveView.RangeFor(