Async Operations
When working with large Save Categories, you may encounter hitches when performing certain operations. Specifically:
- Opening Profile Categories
- Saving
- Loading
These operations serialize data to/from files, and opening categories performs various additional logic for each Savefield.
Opening Categories is also heavier when the Category can be displayed in menus, as this requires the creation of additional UObjects to support UMG lists.
Performing these operations asynchronously will avoid potential hitches.
While I can’t say how big is “too big” for every project, I can give some general advice:
Dozens of Savefields, or even a couple hundred, will probably not cause noticeable hitches on Windows.
Note that Large Custom Save Objects will be slower than other Savefields.
Operations that occur during gameplay (like auto-saving) are at greater-risk of causing undesirable hitches, and you may want to make them asynchronous regardless of how much data is saved.
When dealing with performance optimization in your project, profiling is your best tool.
Learn more about CPU profiling in Unreal here.
Tip: Searching for Async functions
To find all Asynchronous functions you can perform with the Proto Profiles Subsystem, search for “async”.
Open Categories Asynchronously
To open profile categories asynchronously, use these functions:
- OpenProfileCategoryAsync - Open a specific Profile Category.
- OpenProfileAsync - Open ALL Categories for a Profile.
When opening asynchronously, a Delegate is passed-in that will be called when the operation completes.
Global Categories are automatically openned when the engine starts, and thus there is no async open operation for them.
Save Categories Asynchronously
To save categories asynchronously, use these functions:
- SaveProfileCategoryAsync - Save a specific Profile Category.
- SaveProfileAsync - Save ALL Categories for a Profile.
- SaveGlobalCategoryAsync - Save a specific Global Category.
- SaveAllGlobalCategoriesAsync- Save ALL Global Categories.
When saving asynchronously, a Delegate is passed-in that will be called when the operation completes.
Load Categories Asynchronously
You typically never need to call Load. Global Categories are loaded automatically when the Engine starts, and Profile Categories are loaded when opened.
These async functions are exposed just in-case.
To load categories asynchronously, use these functions:
- LoadProfileCategoryAsync - Load a specific Profile Category.
- LoadProfileAsync - Load ALL Categories for a Profile.
When loading asynchronously, a Delegate is passed-in that will be called when the operation completes.
Async Example
One of the example levels included with the plugin is ExampleAsync. You can run this map to compare synchronous and asynchronous operations with very large Categories of data. You can also reference its Blueprint as an example for how to call these functions.
If you are unsure how to access the example content, please refer to the Quick Start Guide.