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

Upgrading from 1.11.0 to 2.0.0 PostLateNetworkUpdate performance #3083

Open
MadJones opened this issue Sep 29, 2024 · 3 comments
Open

Upgrading from 1.11.0 to 2.0.0 PostLateNetworkUpdate performance #3083

MadJones opened this issue Sep 29, 2024 · 3 comments
Assignees
Labels
Investigating Issue is currently being investigated stat:awaiting response Status - Awaiting response from author. stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report

Comments

@MadJones
Copy link

MadJones commented Sep 29, 2024

Description

I have a world of 400x400 tiles that is filled with Environment Objects such as trees. These are network behaviours with attached network object components. These generally get culled (set active/inactive) depending on player proximity. Generally this stops most updates from happening in 1.11.0. However in 2.0.0 according to the Profiler (see attached screenshot) PostLateNetworkUpdate has an immense impact on performance. Enabling/disabling the gameobjects has no influence on the performance. Only actually destroying the objects will improve the performance in 2.0.0. Looks like a bug to me, but I could be wrong and this is intended behaviour for some reason that I am not aware of.

Reproduce Steps

Upgrade from 1.11.0 NGO to 2.0.0

Expected Outcome

Similiar or better performance.

SCreenshots

1.11.0

Unity_4VSLortxd7

2.0.0

Unity_eqxd7QkRK1

If applicable, add screenshots to help explain your problem.

Environment

OS: Windows
Unity Version: 6000.0.20f1
Netcode Version: 2.0.0

Cheers

@MadJones MadJones added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Sep 29, 2024
@NoelStephensUnity
Copy link
Collaborator

@MadJones

Based on your description, my guess is that:

  • In v1.x.x each NetworkObject used the MonoBehaviour.Update to handle updating scene changed notifications for NetworkObjects, so by disabling the NetworkObjects you were stopping those updates/checks.
  • In v2.x.x NetworkObject no longer uses MonoBehaviour.Update to handle scene changed notifications, and if you don't plan on any of the Environment NetworkObjects in question to change scenes (i.e. be migrated into a new scene) then you can un-check the Scene Migration Synchronization check-box which will not include those NetworkObject instances to check for changes in their scene during the PostLateNetworkUpdate.

This transition between the two versions was to provide a way to exclude that update without having to do any form of scene/distance culling for NetworkObjects that will never need to be synchronized when they are migrated to a different scene.

Check to see if they all have "Scene Migration Synchronization" enabled and if so disable this:
image

Then re-run your profiler and see if that looks more like what you are expecting.

Let me know if this helps?

If not, could you expand the profiler in v2.0.0 to see where the most time is spent?

@NoelStephensUnity NoelStephensUnity added Investigating Issue is currently being investigated stat:awaiting response Status - Awaiting response from author. labels Oct 1, 2024
@NoelStephensUnity NoelStephensUnity self-assigned this Oct 1, 2024
@MadJones
Copy link
Author

@NoelStephensUnity

Thanks, that fixed it for PostLateUpdate.

Out of curiosity, I also saw a lot of performance going into the Ngo1Adapter.RefreshObjectIds. Is there also a way to keep that under control by any means?

msedge_pp6Vt9lMuL

It seems to be part of the NetworkPreUpdate Loop.

Kind regards,

@NoelStephensUnity
Copy link
Collaborator

@MadJones
Good to hear that solved the first performance issue. I think we will make that property default to false/off as a QOL improvement in the next update.

Regarding the Ngo1Adapter, I believe that is part of the Multiplayer Tools package...
I did add some properties to NetworkManager to be able to enable/disable some of the processor intensive portions for profiling purposes:
image

But it would appear that I need to get with the tools group and see if we can provide a mechanism to disable that registration with the network tick event when there is no immediate need for it.

For now, I believe removing the Multiplayer Tools package (temporarily) should remove the Ngo1Adapter and it will no longer register for the network tick event.

Thank you for providing this feedback on your findings! 🥇
These are those little details that make all of the difference when developing. Will follow up on the status of making this more configurable (i.e. some form of property or API to disable the Ngo1Adapter for profiling purposes).
👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigating Issue is currently being investigated stat:awaiting response Status - Awaiting response from author. stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report
Projects
None yet
Development

No branches or pull requests

2 participants