Skip to content

Conversation

kvassall-unity
Copy link
Contributor

No description provided.

@kvassall-unity kvassall-unity requested review from a team September 9, 2021 19:08
Comment on lines 1547 to 1566
var bytesReported = m_NetworkManager.LocalClientId == clientId
? 0
: stream.Length;

if (SceneEventData.SceneEventType == SceneEventData.SceneEventTypes.S2C_Sync)
{
// For this event the server may be sending scene event data about multiple scenes, so we need
// to track a metric for each one.
foreach (var sceneIndex in SceneEventData.ScenesToSynchronize)
{
m_NetworkManager.NetworkMetrics.TrackSceneEventReceived(
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)sceneIndex], stream.Length);
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)sceneIndex], bytesReported);
}
}
else
{
// For all other scene event types, we are only dealing with one scene at a time, so we can read it
// from the SceneEventData directly.
m_NetworkManager.NetworkMetrics.TrackSceneEventReceived(
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)SceneEventData.SceneIndex], stream.Length);
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)SceneEventData.SceneIndex], bytesReported);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is getting refactored in Josie's PR FYI

@becksebenius-unity
Copy link
Contributor

Tests are failing with latest commit. Although I'm a little concerned that it's just the NetworkVariableDelta tests that are failing, not the others. These tests were supposed to validate byte counts.

}

var bytesReported = NetworkManager.LocalClientId == clientId
? 0
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: a comment explaining why we return 0 here might be useful (like "not a failure but success with 0") — also applies to other 0 returning ternaries below.

Copy link
Contributor

@0xFA11 0xFA11 left a comment

Choose a reason for hiding this comment

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

🚀

@kvassall-unity kvassall-unity force-pushed the feature/track_local_execution branch from eea5634 to 5c5647c Compare September 14, 2021 21:22
Comment on lines +1236 to +1238
var bytesReported = m_NetworkManager.LocalClientId == clientId
? 0
: size;
Copy link
Contributor

Choose a reason for hiding this comment

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

Late feedback on this part, but I wonder if it makes sense to add an internal utility function to network manager? Something like m_NetworkManager.GetBytesForMetricReporting(clientId, size);.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean at that point it could be part of the BufferSizeCapture utility class

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, I don't know if BufferSizeCapture should know anything about client ids though. this eval only work if you know networkManager.LocalClientId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is one statement. I don't see too huge of a reason to refactor a single statement into a function

Copy link
Contributor

Choose a reason for hiding this comment

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

I mainly proposed this because you're using the same pattern a bunch of times across the codebase, so it is a bit of a code smell. I agree that for such a small expression it's not a big deal

Copy link
Contributor

@ian-m-unity ian-m-unity Sep 16, 2021

Choose a reason for hiding this comment

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

Yeah, I agree with Beck. I know it's just one statement, but anywhere these functions are used without this statement will be a bug that's inconsistent with the others, so I think there should be a function that can be called that takes care of this ternary as well

@kvassall-unity kvassall-unity force-pushed the feature/track_local_execution branch from 42e1133 to 46a8a76 Compare September 15, 2021 16:54
Comment on lines +227 to +235
var bytesReported = NetworkManager.LocalClientId == client.Key
? 0
: messageSize;
NetworkManager.NetworkMetrics.TrackRpcSent(
client.Key,
NetworkObjectId,
rpcMethodName,
__getTypeName(),
bytesReported);
Copy link
Contributor

@ian-m-unity ian-m-unity Sep 16, 2021

Choose a reason for hiding this comment

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

This pattern of computing bytesReported is repeated so often that personally I think it should be extracted out to other function(s) before merging. As is this is a little fragile, because any of these Track functions called without the ternary will be result in bugs as their behavior will be inconsistent with the rest. I think this work could be done in the NetworkMetrics Track functions themselves, so that at least all of this is taken care of in one file if it can't be done in a single function.

using NUnit.Framework;
using Unity.Multiplayer.Tools.MetricTypes;
using Unity.Netcode.RuntimeTests.Metrics.Utility;
using Unity.Netcode.RuntimeTests.Metrics.Utlity;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be removed now too?

@becksebenius-unity
Copy link
Contributor

becksebenius-unity commented Sep 16, 2021

I think there's still a few missing test updates - it looks like the test pattern worked for the ones you added which is great, but you've modified more cases than the tests you've updated and I think it's important that the change in behavior is verified for all the cases. For example, the Object Destroy case was updated to report 0 for local execution but the test wasn't updated to verify it. I think it should be as simple as applying your new method to those tests though

@kvassall-unity
Copy link
Contributor Author

I think there's still a few missing test updates - it looks like the test pattern worked for the ones you added which is great, but you've modified more cases than the tests you've updated and I think it's important that the change in behavior is verified for all the cases. For example, the Object Destroy case was updated to report 0 for local execution but the test wasn't updated to verify it. I think it should be as simple as applying your new method to those tests though

TrackNetworkObjectDestroySentMetric
This already has the appropriate Assert call.
Could you just mark the tests that you think have missing tests?
I thought i got them all

@becksebenius-unity
Copy link
Contributor

I think there's still a few missing test updates - it looks like the test pattern worked for the ones you added which is great, but you've modified more cases than the tests you've updated and I think it's important that the change in behavior is verified for all the cases. For example, the Object Destroy case was updated to report 0 for local execution but the test wasn't updated to verify it. I think it should be as simple as applying your new method to those tests though

TrackNetworkObjectDestroySentMetric
This already has the appropriate Assert call.
Could you just mark the tests that you think have missing tests?
I thought i got them all

Oh, sorry about that. Somehow I missed it!

@kvassall-unity kvassall-unity merged commit 16d9850 into develop Sep 16, 2021
@kvassall-unity kvassall-unity deleted the feature/track_local_execution branch September 16, 2021 20:35
SamuelBellomo added a commit that referenced this pull request Sep 17, 2021
…ty-Technologies/com.unity.multiplayer.mlapi into sam/feature/client-network-transform

* 'sam/feature/client-network-transform' of github.com:Unity-Technologies/com.unity.multiplayer.mlapi:
  fix: Report messages properly that are locally executed as 0 bytes (#1162)
SamuelBellomo added a commit that referenced this pull request Sep 17, 2021
…transform-teleport

* sam/feature/client-network-transform:
  adding some tests todo
  all current tests pass
  fixed tests, interpolation was depending on network manager singleton, this didn't do well in multiinstance tests
  removing useless comments
  removing useless sample, adding delta input per Matt's design
  missing private
  adding compression, owner check, dirty check
  adding input based transform sample
  fixing CI issues
  test: build multiprocesstestplayer and add it to project tests job (#1174)
  reenabling net transform tests
  fix: Report messages properly that are locally executed as 0 bytes (#1162)
mollstam pushed a commit to Keepsake-Games/com.unity.netcode.gameobjects that referenced this pull request Feb 13, 2023
…nity-Technologies#1162)

* fix: Report messages properly that are locally executed as 0 bytes

* Fix: we can run tests from internal classes

* fix: whitespace

* chore: Fixing namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants