Skip to content

perf: Reduce Message Noise#3979

Open
MrGadget1024 wants to merge 20 commits intomasterfrom
ReduceMsgNoise
Open

perf: Reduce Message Noise#3979
MrGadget1024 wants to merge 20 commits intomasterfrom
ReduceMsgNoise

Conversation

@MrGadget1024
Copy link
Collaborator

@MrGadget1024 MrGadget1024 commented Feb 9, 2025

Fixes #3828

High Ping frequency and TimeSnapshotMessage are only needed when NT's / PredictedRB's are actively used in the game

  • Prevents TimeSnapshotMessage sending when no NT's
  • Uses 2s Ping frequency when no NT's / PredictedRB's
  • NetworkTime has a static ulong highPingComponents
    • NTBase and NTHybrid increment / decrement via OnEnable / OnDisable
    • PredictedRigidbody increments / decrements via OnEnable / OnDisable
  • Tests updated to use DefaultPingInterval, now internal static instead of const

Tested with PlayerTest, Basic, BilliardsPredicted, and Room examples

  • PlayerTest works as expected using all NT prefabs
  • Basic example has no NT's, works as expected with low noise
  • BilliardsPredicted works as expected
  • Room example only uses NT in Game scene, not in Online scene
    • Logging shows the higher msg traffic in Game scene only, not in Online scene (correct)
    • Logging shows the reduced msg traffic when in Online Scene, even when switching back to Online scene from Game scene

High Ping frequency and TimeSnapshotMessage are only needed when NT's are actively used in the game
- Prevents TimeSnapshotMessage sending when no NT's
- Uses 2s Ping frequency when no NT's
- NetworkTime has a `static ulong activeNTs'
  - NTBase and NTHybrid increment / decrement via OnEnable / OnDisable
- Tests updated to use DefaultPingInterval, now internal static instead of const

Tested with PlayerTest, Basic, and Room examples
- PlayerTest works as expected using all NT prefabs
- Basic example has no NT's, works as expected with low noise
- Room example only uses NT in Game scene, not in Online scene
  - Logging shows the higher msg traffic in Game scene only, not in Online scene (correct)
  - Logging shows the reduced msg traffic when in Online Scene, even when switching back to Online scene from Game scene
@MrGadget1024 MrGadget1024 added enhancement New feature or request Awaiting Review labels Feb 9, 2025
@MrGadget1024 MrGadget1024 requested a review from miwarnec February 9, 2025 15:21
@realQuartzi
Copy link

Why is NetworkTime the class that is tracking the count of NetworkTransforms? Is it the only static class we have available at this time?
I personally do not see a problem with it, but it seems kind of weird to look at. otherwise lgtm

@MrGadget1024
Copy link
Collaborator Author

Why is NetworkTime the class that is tracking the count of NetworkTransforms?

A few reasons:

  • It's a neutral class that operates on both server and clients
  • Dependency chain accessibility from the Mirror.Components assembly
  • It has to know the count to return the correct PingInterval

Basically, any component (NT, PredictedRB, future others) has to tell NetworkTime they're alive, so the rest of Mirror uses the correct timing and sends the required messages.

@MrGadget1024 MrGadget1024 changed the title fix: Reduce Message Noise perf: Reduce Message Noise Feb 21, 2025
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 35.00000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.68%. Comparing base (ef974ba) to head (dc22f58).

Files with missing lines Patch % Lines
...omponents/PredictedRigidbody/PredictedRigidbody.cs 0.00% 7 Missing ⚠️
...omponents/NetworkTransform/NetworkTransformBase.cs 25.00% 3 Missing ⚠️
Assets/Mirror/Core/NetworkClient.cs 0.00% 2 Missing ⚠️
Assets/Mirror/Core/NetworkServer.cs 50.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (35.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3979      +/-   ##
==========================================
- Coverage   42.71%   42.68%   -0.04%     
==========================================
  Files         150      150              
  Lines       14623    14639      +16     
==========================================
+ Hits         6246     6248       +2     
- Misses       8377     8391      +14     
Flag Coverage Δ
unittests 42.68% <35.00%> (-0.04%) ⬇️
unity-6000.3.2f1 42.68% <35.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Mirror/Core/NetworkConnectionToClient.cs 100.00% <ø> (ø)
Assets/Mirror/Core/NetworkTime.cs 90.56% <100.00%> (+0.56%) ⬆️
Assets/Mirror/Core/NetworkServer.cs 68.54% <50.00%> (-0.07%) ⬇️
Assets/Mirror/Core/NetworkClient.cs 83.24% <0.00%> (-0.09%) ⬇️
...omponents/NetworkTransform/NetworkTransformBase.cs 40.11% <25.00%> (-0.35%) ⬇️
...omponents/PredictedRigidbody/PredictedRigidbody.cs 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JesusLuvsYooh JesusLuvsYooh self-assigned this Feb 27, 2026
@JesusLuvsYooh JesusLuvsYooh self-requested a review February 27, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting Review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bandwidth Abuse

4 participants