perf/refactor: async task execution for player SaveManager#3050
Closed
perf/refactor: async task execution for player SaveManager#3050
Conversation
Co-Authored-By: Renato Machado <mehah@users.noreply.github.com>
293eabd to
2cef00f
Compare
Converted to miliseconds and set the "done_at" to unique key.
219bb34 to
e8639c7
Compare
phacUFPE
requested changes
Nov 3, 2024
Iterating with "for" range based on phmap::flat_hash_map is very expensive.
38e8a84 to
7f21324
Compare
d4344ad to
352d80d
Compare
|
Contributor
|
This PR is stale because it has been open 45 days with no activity. |
|
Contributor
|
This PR is stale because it has been open 45 days with no activity. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
This implements a new approach for executing player-related save tasks asynchronously using a task-based model. The change allows for tasks to be stored in a vector and later executed as a batch, which reduces the load on the main game thread and improves the efficiency of player data persistence. Each task is added to the Save Manager as a lambda function, allowing flexibility for handling various save operations (e.g., player inventory, stash, storage). The solution aims to ensure that tasks are executed in the same order they were added, addressing the potential bottlenecks in high-load scenarios.
Replacement of
std::ostringstreamwithfmt::formatin load/save functions:All instances of
std::ostringstreamwere replaced byfmt::format. This change results in several improvements:fmt::formatis generally faster and more efficient compared tostd::ostringstreamwhen constructing strings, especially in high-load scenarios.fmt::formatimproves code readability, making string formatting more concise and reducing verbosity.fmt::formatreduces the risk of common errors that occur with multiple chained<<operators, leading to more robust and maintainable code.Behaviour
Actual
Expected
Type of change
How Has This Been Tested
Checklist
Improvements in Player Storage, Stash, and Forge History
Summary of Changes:
Centralization into Separate Classes:
The functionalities related to player storage, stash, and forge history have been organized into individual classes under a new folder named "components." This separation enhances code maintainability and readability, ensuring each component is modular and well-defined.
Caching System for Modified Items Only:
A caching mechanism was introduced to only save information that has been modified. Instead of saving all data related to the player, the system tracks modified or removed keys/items, significantly improving save efficiency. This reduces redundant save operations and minimizes database load.
Unique Key for Forge History (
done_at):For the Forge History system, a unique key (
done_at) was added to ensure precise control over what needs to be saved. This modification allows for selective updates, meaning only records that were changed will be saved, leading to improved consistency and optimized performance when dealing with large data sets.These enhancements collectively contribute to improving the scalability and efficiency of the system, reducing the performance overhead caused by frequent save operations.