Skip to content

Commit f9fc5d7

Browse files
committed
Increase shared buffer size for diagnostic logging. This hsould be fine since its shared.
1 parent 27bf8e7 commit f9fc5d7

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

src/IKVM.CoreLib/Buffers/MemoryBufferWriter.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,13 @@ public Span<T> GetSpan(int sizeHint = 0)
177177
void CheckBuffer(int sizeHint)
178178
{
179179
if (sizeHint < 0)
180-
throw new ArgumentException(nameof(sizeHint));
180+
throw new ArgumentException("SizeHint must be greater than or equal to zero.", nameof(sizeHint));
181181

182182
if (sizeHint == 0)
183-
{
184183
sizeHint = 1;
185-
}
186184

187185
if (sizeHint > FreeCapacity)
188-
{
189186
throw new InvalidOperationException("Buffer size is lower than requested.");
190-
}
191187

192188
Debug.Assert(FreeCapacity > 0 && FreeCapacity >= sizeHint);
193189
}

src/IKVM.CoreLib/Diagnostics/JsonDiagnosticFormat.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static class JsonDiagnosticFormat
2929
/// <param name="writer"></param>
3030
public static void Write(int id, DiagnosticLevel level, string message, object?[] args, Exception? exception, DiagnosticLocation location, TextWriter writer)
3131
{
32-
var buffer = MemoryPool<byte>.Shared.Rent(8192);
32+
var buffer = MemoryPool<byte>.Shared.Rent(65535);
3333

3434
try
3535
{
@@ -55,7 +55,7 @@ public static void Write(int id, DiagnosticLevel level, string message, object?[
5555
/// <param name="writer"></param>
5656
public static async ValueTask WriteAsync(int id, DiagnosticLevel level, string message, object?[] args, Exception? exception, DiagnosticLocation location, TextWriter writer, CancellationToken cancellationToken)
5757
{
58-
var buffer = MemoryPool<byte>.Shared.Rent(8192);
58+
var buffer = MemoryPool<byte>.Shared.Rent(65535);
5959

6060
try
6161
{
@@ -95,7 +95,7 @@ public static void Write<TWriter>(int id, DiagnosticLevel level, string message,
9595
// if we're not writing UTF8, stage to a temporary buffer
9696
if (encoding is not UTF8Encoding)
9797
{
98-
mem = MemoryPool<byte>.Shared.Rent(8192);
98+
mem = MemoryPool<byte>.Shared.Rent(65535);
9999
buf = new MemoryBufferWriter<byte>(mem.Memory);
100100
}
101101

src/IKVM.CoreLib/Diagnostics/TextDiagnosticFormat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static class TextDiagnosticFormat
2929
/// <param name="writer"></param>
3030
public static void Write(int id, DiagnosticLevel level, string message, object?[] args, Exception? exception, DiagnosticLocation location, TextWriter writer)
3131
{
32-
var buffer = MemoryPool<byte>.Shared.Rent(8192);
32+
var buffer = MemoryPool<byte>.Shared.Rent(65535);
3333

3434
try
3535
{
@@ -56,7 +56,7 @@ public static void Write(int id, DiagnosticLevel level, string message, object?[
5656
/// <param name="cancellationToken"></param>
5757
public static async ValueTask WriteAsync(int id, DiagnosticLevel level, string message, object?[] args, Exception? exception, DiagnosticLocation location, TextWriter writer, CancellationToken cancellationToken)
5858
{
59-
var buffer = MemoryPool<byte>.Shared.Rent(8192);
59+
var buffer = MemoryPool<byte>.Shared.Rent(65535);
6060

6161
try
6262
{

src/IKVM.Tools.Core/Diagnostics/JsonDiagnosticFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public JsonDiagnosticFormatter(JsonDiagnosticFormatterOptions options) :
2828
protected override void WriteImpl(in DiagnosticEvent @event, IDiagnosticChannel channel)
2929
{
3030
var encoding = channel.Encoding ?? Encoding.UTF8;
31-
using var buffer = MemoryPool<byte>.Shared.Rent(8192);
31+
using var buffer = MemoryPool<byte>.Shared.Rent(65535);
3232
var writer = new MemoryBufferWriter<byte>(buffer.Memory);
3333
JsonDiagnosticFormat.Write(@event.Diagnostic.Id, @event.Diagnostic.Level, @event.Diagnostic.Message, @event.Args, @event.Exception, @event.Location, ref writer, encoding);
3434
WriteLine(writer, encoding);

src/IKVM.Tools.Core/Diagnostics/TextDiagnosticFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public TextDiagnosticFormatter(TextDiagnosticFormatterOptions options) :
2828
protected override void WriteImpl(in DiagnosticEvent @event, IDiagnosticChannel channel)
2929
{
3030
var encoding = channel.Encoding ?? Encoding.UTF8;
31-
using var buffer = MemoryPool<byte>.Shared.Rent(8192);
31+
using var buffer = MemoryPool<byte>.Shared.Rent(65535);
3232
var writer = new MemoryBufferWriter<byte>(buffer.Memory);
3333
TextDiagnosticFormat.Write(@event.Diagnostic.Id, @event.Diagnostic.Level, @event.Diagnostic.Message, @event.Args, @event.Exception, @event.Location, ref writer, encoding);
3434
WriteLine(writer, encoding);

0 commit comments

Comments
 (0)