Skip to content

Commit 3b9b812

Browse files
fix: Rename 'Send Queue Batch Size' field in adapter (1.0.0) (#1585)
1 parent 4be8457 commit 3b9b812

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

com.unity.netcode.adapter.utp/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44

5+
## [Unreleased]
6+
7+
### Added
8+
9+
### Changed
10+
11+
- Rename the 'Send Queue Batch Size' property to 'Max Payload Size' to better reflect its usage. (#1585)
12+
13+
### Fixed
14+
515
## [1.0.0-pre.4] - 2022-01-04
616

717
### Added

com.unity.netcode.adapter.utp/Runtime/UnityTransport.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using UnityEngine;
4+
using UnityEngine.Serialization;
45
using NetcodeNetworkEvent = Unity.Netcode.NetworkEvent;
56
using TransportNetworkEvent = Unity.Networking.Transport.NetworkEvent;
67
using Unity.Collections.LowLevel.Unsafe;
@@ -85,8 +86,8 @@ private enum State
8586
}
8687

8788
public const int InitialMaxPacketQueueSize = 128;
88-
public const int InitialBatchQueueSize = 6 * 1024;
89-
public const int InitialMaxSendQueueSize = 16 * InitialBatchQueueSize;
89+
public const int InitialMaxPayloadSize = 6 * 1024;
90+
public const int InitialMaxSendQueueSize = 16 * InitialMaxPayloadSize;
9091

9192
private static ConnectionAddressData s_DefaultConnectionAddressData = new ConnectionAddressData()
9293
{ Address = "127.0.0.1", Port = 7777 };
@@ -103,9 +104,9 @@ private enum State
103104
"Basically this is how many packets can be sent/received in a single update/frame.")]
104105
[SerializeField] private int m_MaxPacketQueueSize = InitialMaxPacketQueueSize;
105106

106-
[Tooltip("The maximum size of a batched send. The send queue accumulates messages and batches them together " +
107-
"up to this size. This is effectively the maximum payload size that can be handled by the transport.")]
108-
[SerializeField] private int m_SendQueueBatchSize = InitialBatchQueueSize;
107+
[Tooltip("The maximum size of a payload that can be handled by the transport.")]
108+
[FormerlySerializedAs("m_SendQueueBatchSize")]
109+
[SerializeField] private int m_MaxPayloadSize = InitialMaxPayloadSize;
109110

110111
[Tooltip("The maximum size in bytes of the transport send queue. The send queue accumulates messages for " +
111112
"batching and stores messages when other internal send queues are full. If you routinely observe an " +
@@ -639,9 +640,9 @@ public override void Initialize()
639640

640641
m_NetworkSettings = new NetworkSettings(Allocator.Persistent);
641642

642-
// If the user sends a message of exactly m_SendQueueBatchSize in length, we need to
643+
// If the user sends a message of exactly m_MaxPayloadSize in length, we need to
643644
// account for the overhead of its length when we store it in the send queue.
644-
var fragmentationCapacity = m_SendQueueBatchSize + BatchedSendQueue.PerMessageOverhead;
645+
var fragmentationCapacity = m_MaxPayloadSize + BatchedSendQueue.PerMessageOverhead;
645646

646647
m_NetworkSettings
647648
.WithFragmentationStageParameters(payloadCapacity: fragmentationCapacity)
@@ -660,9 +661,9 @@ public override NetcodeNetworkEvent PollEvent(out ulong clientId, out ArraySegme
660661

661662
public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDelivery networkDelivery)
662663
{
663-
if (payload.Count > m_SendQueueBatchSize)
664+
if (payload.Count > m_MaxPayloadSize)
664665
{
665-
Debug.LogError($"Payload of size {payload.Count} larger than configured 'Send Queue Batch Size' ({m_SendQueueBatchSize}).");
666+
Debug.LogError($"Payload of size {payload.Count} larger than configured 'Max Payload Size' ({m_MaxPayloadSize}).");
666667
return;
667668
}
668669

@@ -671,7 +672,7 @@ public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDel
671672
var sendTarget = new SendTarget(clientId, pipeline);
672673
if (!m_SendQueue.TryGetValue(sendTarget, out var queue))
673674
{
674-
queue = new BatchedSendQueue(Math.Max(m_MaxSendQueueSize, m_SendQueueBatchSize));
675+
queue = new BatchedSendQueue(Math.Max(m_MaxSendQueueSize, m_MaxPayloadSize));
675676
m_SendQueue.Add(sendTarget, queue);
676677
}
677678

com.unity.netcode.adapter.utp/Tests/Runtime/Helpers/DriverClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class DriverClient : MonoBehaviour
3636
private void Awake()
3737
{
3838

39-
var maxCap = UnityTransport.InitialBatchQueueSize + 128;
39+
var maxCap = UnityTransport.InitialMaxPayloadSize + 128;
4040

4141
var settings = new NetworkSettings();
4242
settings.WithFragmentationStageParameters(payloadCapacity: maxCap);

com.unity.netcode.adapter.utp/Tests/Runtime/TransportTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public IEnumerator SendMaximumPayloadSize([ValueSource("k_DeliveryParameters")]
128128

129129
yield return WaitForNetworkEvent(NetworkEvent.Connect, m_ServerEvents);
130130

131-
var payload = new ArraySegment<byte>(new byte[UnityTransport.InitialBatchQueueSize]);
131+
var payload = new ArraySegment<byte>(new byte[UnityTransport.InitialMaxPayloadSize]);
132132
m_Client1.Send(m_Client1.ServerClientId, payload, delivery);
133133

134134
yield return WaitForNetworkEvent(NetworkEvent.Data, m_ServerEvents);

0 commit comments

Comments
 (0)