Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(skymp5-server): avoid copying in DynamicFields.set (mp.set) #2265

Merged
merged 9 commits into from
Dec 14, 2024

Conversation

nic11
Copy link
Collaborator

@nic11 nic11 commented Dec 12, 2024

Important

Optimize DynamicFields::Set to avoid copying and refactor message handling in MpObjectReference for improved performance.

  • Performance:
    • Optimize DynamicFields::Set in DynamicFields.cpp by using std::move to avoid unnecessary copying of nlohmann::json objects.
  • Refactoring:
    • Replace SendPropertyToListeners and SendPropertyTo with SendMessageToActorListeners in MpObjectReference.cpp for sending messages to actor listeners.
    • Refactor SetProperty in MpObjectReference.cpp to use std::move for nlohmann::json parameter.
  • Misc:
    • Include MessageBase.h and UpdatePropertyMessage.h in MpObjectReference.cpp and MpObjectReference.h for message handling.

This description was created by Ellipsis for 8a3b750. It will automatically update as commits are pushed.

@nic11
Copy link
Collaborator Author

nic11 commented Dec 13, 2024

Ideally should spend some more time on indev(?) because of potential untesed error (host)

@nic11 nic11 marked this pull request as ready for review December 14, 2024 11:16
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 8a3b750 in 13 seconds

More details
  • Looked at 219 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp:704
  • Draft comment:
    Consider changing the parameter type of newValue in CreatePropertyMessage and PreparePropertyMessage to pass by value and use std::move to avoid unnecessary copies, similar to the change made in SetProperty.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The change from passing by const reference to pass by value and using std::move is a performance improvement. However, the same change should be applied consistently across the codebase.

Workflow ID: wflow_0dB0JNgOmH9HZf5C


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@Pospelove Pospelove merged commit b5a603d into skyrim-multiplayer:main Dec 14, 2024
10 checks passed
@Pospelove Pospelove deleted the mpset-nocopy branch December 14, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants