Commit Graph

47 Commits

Author SHA1 Message Date
johan torp
146b21d3d4 GC reachability optimizations. ~1.5x speedup and ~2.5MB memory saved for an internal title.
List of optimizations and changes:
* Token stream structure
    * Split token stream into strong-only and a mixed (weak+strong) stream
    * Split token stream into a builder and a tighter view class which reduces sizeof(UClass)
    * Implemented ref-counted token stream view sharing
    * Removed Class and Outer from token stream
    * Allow empty token streams (enabled by removing Class/Outer) to avoid touching token stream data
    * Placed ARO (AddReferencedObjects) last to reduce per object cache thrashing, improve control flow predicability and avoid reading the last EndOfPointer and EndOfStream tokens
    * FPrefetchingObjectIterator that bring in Class/Outer, class' tokenstream view and the first token data ahead of time
    * Decode token bitfield once and ahead of time
* Reference queues and batch processing
    * Introduced bounded queues: ref arrays -> unvalidated refs -> validated (non-null / non-permanent) refs
    * Split all these queues for killable vs immutable references
    * Stack-living references still handled synchronously. With removal of Class/Outer (prefetched ahead of time) few instances remain outside of ARO calls.
    * Outer queues hold 32 items and get flushed when full.
* AddReferencedObjects (ARO) optimizations
    * Misc optimizations in many ARO implementations
    * New FReferenceCollector API to queue up ARO references (AddStableReference), old sync API (HandleObjectReference) still available
    * New AddPropertyReferences traversal that replaces SerializeBin and PropertyValueIterator
        * 4.5x faster than PropertyValueIterator
        * Uses CLASSCAST dispatch instead of virtual SerializeItem dispatch.
        * Step towards new unified token stream replacement shared by class token processing, structs and ARO
    * Replaced StructUtil::AddReferencedObjects with AddPropertyReferences traversal, ~8x speedup and collects more references for CitySample
* Parallelism
    * Single long-running task per worker
    * Improved work-stealing / load-balancing, workers can steal full blocks, ARO calls and initial references
    * Queue up slow ARO calls to improve load balancing and avoid late stragglers. Motivated by certain ARO calls taking over 2ms for a few specific objects.
    * Kick tasks manually to avoid ParallelFor end synchronization
* FGCObject
    * Initial reference collector runs in parallel with mark phase
    * New FGCObject constructor API (AddStableNativeReferencesOnly) to opt-in to initial reference collection, used by StreamableManager
    * Same constructor API allows FGCObjects to defer registration until they become active (RegisterLater), reduces number of active GCObjects
* Reduced memory usage
    * Allocate reached objects in scratch pages (FWorkBlock) and reuse processed blocks, instead of swapping two big TArray<UObject*> per worker
    * Reduced sizeof(UClass)
    * Shareable token streams
* Misc optimizations
    * New API to test if an object is in the permanent object pool. Old API read two global pointers for every visited reference.
    * Fixed signed integer usage in GUObjectArray lookup that led to bad codegen
    * FPropertyIterator optimizations
    * SerializeBin optimizations
* Other changes
    * Moved many helpers into UE::GC namespace
    * Replaced TFastReferenceCollector API with simplified CollectReferences call. Needed to break this API  any way.
    * Introduced FGCInternals to avoid forward-declaring TFastReferenceCollector and depend on the options enum in common headers
    * Moved and outlined code from GarbageCollection.h / FastReferenceCollector.h to GarbageCollection.cpp
    * Moved GC History and Garbage Reference Tracking into a synchronous TDebugReachabilityProcessor
    * Removed PersistentGarbage flag since it wasn't used in practice
    * Improved const correctness

#rb robert.millar,robert.manuszewski,pj.kack
#preflight 63945bf45624e6da5ec85f88
#jira UE-169791

[CL 23475562 by johan torp in ue5-main branch]
2022-12-11 23:21:18 -05:00
mikko mononen
fe252a1f95 StructUtils: Renamed FInstancedStructArray to FInstancedStructContainer
#jira UE-170863
#rb Mieszko.Zielinski
#preflight 638debbb7e0feab0b7da3359

[CL 23389832 by mikko mononen in ue5-main branch]
2022-12-05 09:16:27 -05:00
mikko mononen
de58b75795 StateTree: Be more resilient when loading out of date BP data
- Try to convert to latest version when duplicating data
- Convert property binding source/target classes to latest version on link
- Handle BP reference replace in instanced structs

#rb Mieszko.Zielinski
#preflight 638d97e0303395f6c97629fd

[CL 23387730 by mikko mononen in ue5-main branch]
2022-12-05 03:19:45 -05:00
mikko mononen
1cc286a596 StateTree: Add indirection to FStateTreeInstanceData so that it can be bitwise relocated.
#rb Mieszko.Zielinski
#preflight 63872b0d3377450900b579a6

[CL 23325782 by mikko mononen in ue5-main branch]
2022-11-30 07:17:26 -05:00
Matt Peters
2d5975f362 IncrementalCooking - Add DeclareConstructClasses to types that need it.
#rb Zousar.Shaker
#rnx
#preflight 63811e084004f73f62dee973

[CL 23268593 by Matt Peters in ue5-main branch]
2022-11-25 15:40:13 -05:00
bryan sefcik
50d4fac9e0 Updated ../Engine/Plugins/... to inline gen.cpp files
Before:
3548 unity files
Total CPU Time: 47343.578125 s
Total time in Parallel executor: 494.60 seconds

After:
3445 unity files
Total CPU Time: 46044.671875 s
Total time in Parallel executor: 468.51 seconds

#jira
#preflight 63336159b20e73a098b7f24f

[CL 22218213 by bryan sefcik in ue5-main branch]
2022-09-28 01:06:15 -04:00
luciano ferraro
c95984a115 Moved AddReferencedObjects implementation out of an editor guard
#jira
#preflight skip

[CL 22173119 by luciano ferraro in ue5-main branch]
2022-09-24 13:28:43 -04:00
luciano ferraro
810eb58a1b Fix crash issue with condition instances not being reflected to GC
#jira
[REVIEW] [at]Mikko.Mononen
[FYI] Loic.Devaux, Josselin.Francois, Nicolas.Bonnelly, Phil.Cole
#preflight 632ca19310030508067245c2

[CL 22173118 by luciano ferraro in ue5-main branch]
2022-09-24 13:28:37 -04:00
mikko mononen
ab1b7f80cf StateTree: fix test and empty parameters
- handle empty subtree parameters
- changed a compiler check() to an error
- fixed tests

#jira UE-164541
#rb Mieszko.Zielinski
#preflight 632c4e77671a1a24b5ff67a6

[CL 22163478 by mikko mononen in ue5-main branch]
2022-09-23 19:58:36 -04:00
mikko mononen
0d47d49765 StateTree: Context Objects
- Cleaned up Blueprint nodes from deprecated functions
- Added call guards for BP implemented events on BP nodes
- Renamed Named External Data to Context (Object/Data)
- Added automatic binding for Context objects
- Added UI visualization for Context properties and cleaned up the Input/Ouput visualization
- Added compiler errors for missing Input and Context properties

#jira UE-156544 UE-147509
#rb Stephen.Holmes

[CL 22084585 by mikko mononen in ue5-main branch]
2022-09-19 19:47:11 -04:00
mikko mononen
aa99e51c55 StateTree: Compile StateTree on load if in older format.
#preflight 6322e4a536768f8cf385ced2
#rb Mieszko.Zielinski

[CL 22033017 by mikko mononen in ue5-main branch]
2022-09-15 13:53:23 -04:00
mikko mononen
b908187acc StateTree: Fix WinRT compiler error.
"dynamic initialization of thread local data not allowed in WinRT code"

#rb Mieszko.Zielinski
#preflight 631add4dd135b61bc5479c8e

[CL 21917251 by mikko mononen in ue5-main branch]
2022-09-09 05:14:55 -04:00
mikko mononen
9174cf81d1 StateTree: Threadsafe shared data
- added thread safe access to shared instance data (each thread gets a copy)
- fixed Item->Node in the editor node API

#jira UE-153269
#rb Mieszko.Zielinski

[CL 21862712 by mikko mononen in ue5-main branch]
2022-09-07 17:12:18 -04:00
Marc Audy
f1cbfbd372 Do not error when a state tree needs recompiling in the editor
#codereview Mikko.Mononen
#preflight

[CL 21754835 by Marc Audy in ue5-main branch]
2022-09-02 01:15:02 -04:00
mikko mononen
0d1ace8323 StateTree: StateTreeComponent improvements
- Added option to start the StateTree automatically on BeginPlay
- StateTreeComponentSchema: allow to specify which actor class to expect the StateTree to run on (allows to bind to Actor specific data directly)
- Fixed FStateTreeReference parameter update on BP instance (the struct gets copied, which cause issues with the delegate handle)

#rb Mieszko.Zielinski
#preflight 630c70bb0345de4ccf7c8b51

[CL 21685020 by mikko mononen in ue5-main branch]
2022-08-29 14:47:43 -04:00
mikko mononen
3e852502b6 StateTree: Fixed failing test and missing validation
- fail compilation if linking to non-subtree
- fixed crash in linker if subtree does not have parameters
- fixed subtree test (subtree state was missing type)

#jira UE-155893
#preflight 62d90fd3d54af4b9a2fc04c0

#ROBOMERGE-AUTHOR: mikko.mononen
#ROBOMERGE-SOURCE: CL 21198999 via CL 21199006 via CL 21199009
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)

[CL 21199538 by mikko mononen in ue5-main branch]
2022-07-21 08:19:56 -04:00
mikko mononen
f9887f77bc StateTree: Added schema picker to new tree creation workflow
- Added BP-like class picker for schema when StateTree asset is created
- Added "CommonSchema" meta tag for schemas to allow them to be added to the common list
- Allow the asset on StateTree actor component to EditAnywhere
- Fixed compilation indication for empty StateTrees (was showing red)

#robomerge EngineMerge
#jira UE-151649
#rb Yoan.StAmant
#preflight 62beaeeb8d5e6787590a0921

[CL 20911820 by mikko mononen in ue5-main branch]
2022-07-01 04:36:16 -04:00
mikko mononen
ff9339f006 StateTree: Fixed max instance data memory usage estimate calculation
Root states accumulate max child state memory usage (e.g. most expensive chain) not whole tree.

#robomerge EngineMerge
#jira none
#rb Mieszko-Zielinski
#preflight 62bc34e33771c5710de5e012

[CL 20872323 by mikko mononen in ue5-main branch]
2022-06-29 07:22:15 -04:00
mikko mononen
ee2add5528 StateTree: Prevent linking empty StateTrees (will cause unrelated error)
#jira UE-155893
#robomerge EngineMerge
#rb Yoan.StAmant
#preflight 62b1a2b527718d2d48276e9e

[CL 20755468 by mikko mononen in ue5-main branch]
2022-06-21 06:57:10 -04:00
Ben Marsh
f379f98a78 Fix warning for incorrectly included header.
#preflight none

[CL 20470758 by Ben Marsh in ue5-main branch]
2022-06-02 12:03:12 -04:00
Ben Marsh
727313243d Fix non-unity compile errors.
#preflight none

[CL 20469864 by Ben Marsh in ue5-main branch]
2022-06-02 11:03:50 -04:00
robert manuszewski
d1443992e1 Deprecating ANY_PACKAGE.
This change consists of multiple changes:

Core:
- Deprecation of ANY_PACKAGE macro. Added ANY_PACKAGE_DEPRECATED macro which can still be used for backwards compatibility purposes (only used in CoreUObject)
- Deprecation of StaticFindObjectFast* functions that take bAnyPackage parameter
- Added UStruct::GetStructPathName function that returns FTopLevelAssetPath representing the path name (package + object FName, super quick compared to UObject::GetPathName) + wrapper UClass::GetClassPathName to make it look better when used with UClasses
- Added (Static)FindFirstObject* functions that find a first object given its Name (no Outer). These functions are used in places I consider valid to do global UObject (UClass) lookups like parsing command line parameters / checking for unique object names
- Added static UClass::TryFindType function which serves a similar purpose as FindFirstObject however it's going to throw a warning (with a callstack / maybe ensure in the future?) if short class name is provided. This function is used  in places that used to use short class names but now should have been converted to use path names to catch any potential regressions and or edge cases I missed.
- Added static UClass::TryConvertShortNameToPathName utility function
- Added static UClass::TryFixShortClassNameExportPath utility function
- Object text export paths will now also include class path (Texture2D'/Game/Textures/Grass.Grass' -> /Script/Engine.Texture2D'/Game/Textures/Grass.Grass')
- All places that manually generated object export paths for objects will now use FObjectPropertyBase::GetExportPath
- Added a new startup test that checks for short type names in UClass/FProperty MetaData values

AssetRegistry:
- Deprecated any member variables (FAssetData / FARFilter) or functions that use FNames to represent class names and replaced them with FTopLevelAssetPath
- Added new member variables and new function overloads that use FTopLevelAssetPath to represent class names
- This also applies to a few other modules' APIs to match AssetRegistry changes

Everything else:
- Updated code that used ANY_PACKAGE (depending on the use case) to use FindObject(nullptr, PathToObject), UClass::TryFindType (used when path name is expected, warns if it's a short name) or FindFirstObject (usually for finding types based on user input but there's been a few legitimate use cases not related to user input)
- Updated code that used AssetRegistry API to use FTopLevelAssetPaths and USomeClass::StaticClass()->GetClassPathName() instead of GetFName()
- Updated meta data and hardcoded FindObject(ANY_PACKAGE, "EEnumNameOrClassName") calls to use path names

#jira UE-99463
#rb many.people
[FYI] Marcus.Wassmer
#preflight 629248ec2256738f75de9b32

#codereviewnumbers 20320742, 20320791, 20320799, 20320756, 20320809, 20320830, 20320840, 20320846, 20320851, 20320863, 20320780, 20320765, 20320876, 20320786

#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 20430220 via CL 20433854 via CL 20435474 via CL 20435484
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v949-20362246)

[CL 20448496 by robert manuszewski in ue5-main branch]
2022-06-01 03:46:59 -04:00
mikko mononen
cd197fcb3e StateTree: refactored index types
- Changed FStateTreeHandle to FStateTreeStateHandle, used only for indexing states
- Added uint16 and uin8 index types, which can represent invalid index (aka INDEX_NONE)
- Changed indices that can be optional to the index types above
- Added validation and error loggic when index types overflow during compile
- Removed 2 indirections (in common case) and halved the memory usage of property copies

#jira none
#rb Mieszko.Zielinski
#preflight 6295d26e91004dd61ced370b

[CL 20434838 by mikko mononen in ue5-main branch]
2022-05-31 04:51:18 -04:00
mikko mononen
66e1f36595 StateTree: Changed runtime data to contain only active tasks
- Commented and cleaned up the members of UStateTree a bit
- Changed StateTree Node storage to FInstancedStructArray (contiguous memory)
- Changed StateTree SharedData to FInstancedStructArray
- Changed StateTree instance data to use FInstancedStructArray
- StateTree statistics shows estimated mem usage per state and max for tree (heaviest linked chain)
- Added explicit bLinked state for UStateTree
- Cleaned up UStateTree::ResetCompiled()/ResetLinked()
- Changed StateTree execution context to allocate task instance data on Start() and EnterState()
- StateTree tick uses execution order counters to access the instance data instead of compile time specific index

#jira  UE-153269
#rb Stephen.Holmes Yoan.StAmant
#preflight 628df39faf7a2e956bb45dc5

[CL 20361823 by mikko mononen in ue5-main branch]
2022-05-25 05:34:50 -04:00
mikko mononen
a841531c2b StateTree: moved evaluators global to tree
- Deprecated per state evaluators and moved them to global to the tree
- Tick evals once per Tick()
- Updated editor node customizations to work on UStateTreeEditorData
- Added separate detail customization for UStateTreeEditorData

#jira UE-147508
#rb Yoan.StAmant
#preflight 62820e55046b81bf93911605

[CL 20221385 by mikko mononen in ue5-main branch]
2022-05-16 05:13:27 -04:00