Skip to content

chore: remove all the old profiling code #1048

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

Merged
merged 3 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
421 changes: 0 additions & 421 deletions com.unity.netcode.gameobjects/Editor/NetcodeProfiler.cs

This file was deleted.

11 changes: 0 additions & 11 deletions com.unity.netcode.gameobjects/Editor/NetcodeProfiler.cs.meta

This file was deleted.

118 changes: 0 additions & 118 deletions com.unity.netcode.gameobjects/Editor/NetcodeProfilerModule.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,6 @@ internal static void HandleNetworkVariableDeltas(List<INetworkVariable> networkV
long readStartPos = stream.Position;

networkVariableList[i].ReadDelta(stream, networkManager.IsServer);
PerformanceDataManager.Increment(ProfilerConstants.NetworkVarDeltas);
ProfilerStatManager.NetworkVarsRcvd.Record();
networkManager.NetworkMetrics.TrackNetworkVariableDeltaReceived(clientId, logInstance.NetworkObjectId, logInstance.name, networkVariableList[i].Name, stream.Length);

(stream as NetworkBuffer).SkipPadBits();
Expand Down Expand Up @@ -753,8 +751,6 @@ internal static void HandleNetworkVariableUpdate(List<INetworkVariable> networkV
long readStartPos = stream.Position;

networkVariableList[i].ReadField(stream);
PerformanceDataManager.Increment(ProfilerConstants.NetworkVarUpdates);
ProfilerStatManager.NetworkVarsRcvd.Record();

if (networkManager.NetworkConfig.EnsureNetworkVariableLengthSafety)
{
Expand Down
63 changes: 2 additions & 61 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Unity.Netcode
/// The main component of the library
/// </summary>
[AddComponentMenu("Netcode/" + nameof(NetworkManager), -100)]
public class NetworkManager : MonoBehaviour, INetworkUpdateSystem, IProfilableTransportProvider
public class NetworkManager : MonoBehaviour, INetworkUpdateSystem
{
#pragma warning disable IDE1006 // disable naming rule violation check

Expand Down Expand Up @@ -576,8 +576,6 @@ private void Initialize(bool server)
NetworkConfig.NetworkTransport.ResetChannelCache();

NetworkConfig.NetworkTransport.Init();

ProfilerNotifier.Initialize(this);
}

/// <summary>
Expand Down Expand Up @@ -880,9 +878,6 @@ public void Shutdown()
NetworkTickSystem = null;
}

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.Stop();
#endif
IsListening = false;
IsServer = false;
IsClient = false;
Expand Down Expand Up @@ -938,23 +933,15 @@ public void NetworkUpdate(NetworkUpdateStage updateStage)

private void OnNetworkEarlyUpdate()
{
NotifyProfilerListeners();
ProfilerBeginTick();
NetworkMetrics.DispatchFrame();

if (IsListening)
{
PerformanceDataManager.Increment(ProfilerConstants.ReceiveTickRate);
ProfilerStatManager.RcvTickRate.Record();

#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_TransportPoll.Begin();
#endif
var isLoopBack = false;

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.StartTick(TickType.Receive);
#endif

//If we are in loopback mode, we don't need to touch the transport
if (!isLoopBack)
{
Expand All @@ -969,10 +956,6 @@ private void OnNetworkEarlyUpdate()
} while (IsListening && networkEvent != NetworkEvent.Nothing);
}

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.EndTick();
#endif

#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_TransportPoll.End();
#endif
Expand Down Expand Up @@ -1065,17 +1048,11 @@ internal IEnumerator TimeOutSwitchSceneProgress(SceneSwitchProgress switchSceneP
private void HandleRawTransportPoll(NetworkEvent networkEvent, ulong clientId, NetworkChannel networkChannel,
ArraySegment<byte> payload, float receiveTime)
{
PerformanceDataManager.Increment(ProfilerConstants.ByteReceived, payload.Count);
ProfilerStatManager.BytesRcvd.Record(payload.Count);

switch (networkEvent)
{
case NetworkEvent.Connect:
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_TransportConnect.Begin();
#endif
#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.StartEvent(TickType.Receive, (uint)payload.Count, networkChannel, "TRANSPORT_CONNECT");
#endif
if (IsServer)
{
Expand Down Expand Up @@ -1103,9 +1080,6 @@ private void HandleRawTransportPoll(NetworkEvent networkEvent, ulong clientId, N
StartCoroutine(ApprovalTimeout(clientId));
}

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.EndEvent();
#endif
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_TransportConnect.End();
#endif
Expand All @@ -1124,9 +1098,6 @@ private void HandleRawTransportPoll(NetworkEvent networkEvent, ulong clientId, N
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_TransportDisconnect.Begin();
#endif
#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.StartEvent(TickType.Receive, 0, NetworkChannel.Internal, "TRANSPORT_DISCONNECT");
#endif

if (NetworkLog.CurrentLogLevel <= LogLevel.Developer)
{
Expand All @@ -1145,9 +1116,6 @@ private void HandleRawTransportPoll(NetworkEvent networkEvent, ulong clientId, N

OnClientDisconnectCallback?.Invoke(clientId);

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.EndEvent();
#endif
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_TransportDisconnect.End();
#endif
Expand Down Expand Up @@ -1186,10 +1154,6 @@ internal void HandleIncomingData(ulong clientId, NetworkChannel networkChannel,
var messageType = (MessageQueueContainer.MessageType)messageStream.ReadByte();
MessageHandler.MessageReceiveQueueItem(clientId, messageStream, receiveTime, messageType, networkChannel);
}

#if !UNITY_2020_2_OR_NEWER
NetworkProfiler.EndEvent();
#endif
}
#if DEVELOPMENT_BUILD || UNITY_EDITOR
s_HandleIncomingData.End();
Expand Down Expand Up @@ -1288,8 +1252,6 @@ public void DisconnectClient(ulong clientId)
if (ConnectedClientsList[i].ClientId == clientId)
{
ConnectedClientsList.RemoveAt(i);
PerformanceDataManager.Increment(ProfilerConstants.Connections, -1);
ProfilerStatManager.Connections.Record(-1);
}
}

Expand Down Expand Up @@ -1354,8 +1316,6 @@ internal void OnClientDisconnectFromServer(ulong clientId)
if (ConnectedClientsList[i].ClientId == clientId)
{
ConnectedClientsList.RemoveAt(i);
PerformanceDataManager.Increment(ProfilerConstants.Connections, -1);
ProfilerStatManager.Connections.Record(-1);
break;
}
}
Expand Down Expand Up @@ -1403,9 +1363,6 @@ internal void HandleApproval(ulong ownerClientId, bool createPlayerObject, uint?
ConnectedClients.Add(ownerClientId, client);
ConnectedClientsList.Add(client);

PerformanceDataManager.Increment(ProfilerConstants.Connections);
ProfilerStatManager.Connections.Record();

if (createPlayerObject)
{
var networkObject = SpawnManager.CreateLocalNetworkObject(false, playerPrefabHash ?? NetworkConfig.PlayerPrefab.GetComponent<NetworkObject>().GlobalObjectIdHash, ownerClientId, null, position, rotation);
Expand Down Expand Up @@ -1538,21 +1495,5 @@ private IInternalMessageHandler CreateMessageHandler()

return messageHandler;
}

private void ProfilerBeginTick()
{
ProfilerNotifier.ProfilerBeginTick();
}

private void NotifyProfilerListeners()
{
ProfilerNotifier.NotifyProfilerListeners();
NetworkMetrics.DispatchFrame();
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure we still need this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I just moved it to the original callsite for NotifyProfilerListeners

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}

public ITransportProfilerData Transport
{
get { return NetworkConfig.NetworkTransport as ITransportProfilerData; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public void SendUnnamedMessage(List<ulong> clientIds, NetworkBuffer buffer, Netw
}
}

PerformanceDataManager.Increment(ProfilerConstants.UnnamedMessageSent);
m_NetworkManager.NetworkMetrics.TrackUnnamedMessageSent(clientIds, buffer.Length);
}

Expand Down Expand Up @@ -206,13 +205,12 @@ public void SendNamedMessage(string name, ulong clientId, Stream stream, Network

stream.Position = 0;
stream.CopyTo(nonNullContext.NetworkWriter.GetStream());

var size = bufferSizeCapture.StopMeasureSegment();

m_NetworkManager.NetworkMetrics.TrackNamedMessageSent(clientId, name, size);
}
}
PerformanceDataManager.Increment(ProfilerConstants.NamedMessageSent);
}

/// <summary>
Expand Down Expand Up @@ -259,7 +257,6 @@ public void SendNamedMessage(string name, List<ulong> clientIds, Stream stream,
m_NetworkManager.NetworkMetrics.TrackNamedMessageSent(clientIds, name, size);
}
}
PerformanceDataManager.Increment(ProfilerConstants.NamedMessageSent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,29 +317,17 @@ public void MessageReceiveQueueItem(ulong clientId, Stream stream, float receive
return;
}

if (messageType == MessageQueueContainer.MessageType.ClientRpc ||
messageType == MessageQueueContainer.MessageType.ServerRpc)
{
ProfilerStatManager.RpcsRcvd.Record();
PerformanceDataManager.Increment(ProfilerConstants.RpcReceived);
}

var messageQueueContainer = NetworkManager.MessageQueueContainer;
messageQueueContainer.AddQueueItemToInboundFrame(messageType, receiveTime, clientId, (NetworkBuffer)stream, receiveChannel);
}

public void HandleUnnamedMessage(ulong clientId, Stream stream)
{
PerformanceDataManager.Increment(ProfilerConstants.UnnamedMessageReceived);
ProfilerStatManager.UnnamedMessage.Record();
NetworkManager.CustomMessagingManager.InvokeUnnamedMessage(clientId, stream);
}

public void HandleNamedMessage(ulong clientId, Stream stream)
{
PerformanceDataManager.Increment(ProfilerConstants.NamedMessageReceived);
ProfilerStatManager.NamedMessage.Record();

using (var reader = PooledNetworkReader.Get(stream))
{
ulong hash = reader.ReadUInt64Packed();
Expand Down
Loading