Increase default buffer size; remove diagnostic test/debug

Increased InitialBufferCapacity default to 16 KB in AcBinarySerializerOptions and updated docs. Removed ProtocolRoundTripDiagnosticTest and related diagnostic code from SignalRClientToHubTest.cs. Cleaned up debug output in AcBinaryHubProtocol.cs by removing Debug.WriteLine statements.
This commit is contained in:
Loretta 2026-04-08 11:09:13 +02:00
parent 55e53c248f
commit 3e00876c0f
4 changed files with 3 additions and 33 deletions

View File

@ -126,9 +126,9 @@ public sealed class AcBinarySerializerOptions : AcSerializerOptions
/// <summary>
/// Initial capacity for serialization buffer.
/// Default: 4096 bytes
/// Default: 16384 bytes (16 KB)
/// </summary>
public int InitialBufferCapacity { get; init; } = 4096;d
public int InitialBufferCapacity { get; init; } = 16384;
/// <summary>
/// Chunk size (in bytes) used by <see cref="BufferWriterBinaryOutput"/> when writing to an <see cref="System.Buffers.IBufferWriter{T}"/>.

View File

@ -119,7 +119,7 @@ delegate PropertyInfo? PropertyMapperDelegate(PropertyInfo sourceProperty, Type
| Option | Type | Default | Purpose |
|--------|------|---------|---------|
| `UseGeneratedCode` | bool | `true` | Use source-generated writers/readers when available. Enables SGen root fast path (see `BINARY_SGEN.md`) |
| `InitialBufferCapacity` | int | 4096 | Starting buffer size (bytes) for serialization output |
| `InitialBufferCapacity` | int | 16384 | Starting buffer size (bytes) for serialization output |
| `RemoveOrphanedItems` | bool | `false` | During `PopulateMerge`: remove destination collection items with no matching source ID |
| `UseAsync` | bool | `false` | Async context pool return via ThreadPool. Auto-disabled in WASM and when `ReferenceHandling=None` |
| `MaxContextPoolSize` | int | 8 | Max serialization contexts kept in pool |

View File

@ -1194,34 +1194,6 @@ public abstract class SignalRClientToHubTestBase
/// <summary>
/// Runs all SignalR tests with JSON serialization.
/// </summary>
/// <summary>
/// Diagnostic test: isolates protocol round-trip from the full client-hub flow.
/// </summary>
[TestClass]
public class ProtocolRoundTripDiagnosticTest
{
[TestMethod]
public void Protocol_RoundTrip_BasicInvocation()
{
var protocol = new AyCodeBinaryHubProtocol();
var binder = new TestInvocationBinder();
var signalParams = new SignalParams { Status = SignalResponseStatus.Success };
var invocation = new InvocationMessage(
nameof(IAcSignalRHubClient.OnReceiveMessage),
new object?[] { 42, (int?)1, signalParams, Array.Empty<byte>() });
var bytes = protocol.GetMessageBytes(invocation);
// Diagnostic: dump first bytes
var arr = bytes.ToArray();
var lengthPrefix = BitConverter.ToInt32(arr, 0);
var firstByte = arr.Length > 4 ? arr[4] : (byte)0;
Assert.Fail($"Bytes={arr.Length}, LengthPrefix={lengthPrefix}, Remaining={arr.Length - 4}, " +
$"FirstPayloadByte=0x{firstByte:X2}, First16={BitConverter.ToString(arr, 0, Math.Min(16, arr.Length))}");
}
}
[TestClass]
public class SignalRClientToHubTest_Json : SignalRClientToHubTestBase

View File

@ -395,10 +395,8 @@ public class AcBinaryHubProtocol : IHubProtocol
private void WriteArgument(ref BufferWriterBinaryOutput bw, IBufferWriter<byte> output, object? value, ref int externalBytes)
{
Debug.WriteLine($"WriteArgument invoked");
if (value is byte[] byteArray)
{
Debug.WriteLine($"WriteArgument value is byte[] byteArray");
// byte[] fast-path: size known upfront, write entirely through BWO
var argPayload = 1 + VarUIntSize((uint)byteArray.Length) + byteArray.Length;