Eliminate memory pressure/garbage generation in sim performance critical path #1731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Release
conditional Log methods that create garbage regardless of conditionPoolList<T>
where applicableAssertion
type to avoid boxing, fix possibleNullReferenceException
while logging anException
😂Notifier
class. Avoids creating uselessSimulation Action
and also eliminates garbage that would be generated by instantiating objects args andAction
delegate itselfImportant note after checking compiled code in
Release
targetDebug guarded calls with lambdas or delegates capturing local variable (
debugOverlay
inUpdatePathTargetPositionsPatch.cs
captures Bezier3 variable) can still trigger generation of<>DisplayClass
helper classes, and most importantly use the instance of helper class to move captured variable around even if debug guarded code is not used explicitly anywhere in the method.Other notes
Lambda/Delegate capturing local variable generates
<>DisplayClass
which instance in most cases is created in the first line of the method, regardless of where it be actually used, so compiler will generate instantiation code just for passing captured value around, even if you guard the explicit call with multiple conditions, includingconst
.TODO for the future PR
Redesign
SegmentTraverser
andSegmentLaneTraverser
since currently they are multi-level garbage generators with lambdas capturing other lambdas, capturing local variables, not to mention that one runs recursively.Used on the main thread, mostly for displaying mod overlays like clickable Speed limits signs handles, Parking restrictions etc.
Build ZIP