Skip to content

Instantly share code, notes, and snippets.

View antonfirsov's full-sized avatar

Anton Firszov antonfirsov

View GitHub Profile

Bmp - main

Method TestImage Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
'ImageSharp Bmp' Bmp/Car.bmp 86.65 us 24.70 us 1.354 us 0.1221 - - 2 KB

Bmp - PR

Method TestImage Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
#define METRICS
using System.Diagnostics.Metrics;
using BenchmarkDotNet.Attributes;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks.Sources;
using System.Net;
#if METRICS
using BenchmarkDotNet.Attributes;
using System.Collections.Frozen;
[MemoryDiagnoser]
public class StatusCodeBoxingBenchmarks
{
[Benchmark]
public object Get1_FrozenDictionary()
{
return GetBoxedStatusCode_FrozenDictionary(200);
@antonfirsov
antonfirsov / ProtocolExceptions.MD
Last active June 9, 2022 16:42
Exposing HTTP/2 and HTTP/3 protocol error details from `SocketsHttpHandler`

Exposing HTTP/2 and HTTP/3 protocol error details from SocketsHttpHandler

This proposal builds on the decisions made in our QUIC Exceptions Design proposal.

Proposed design

  • Define a new exception type ProtocolException, and embed it as HttpRequestException.InnerException
  • Throw ProtocolException directly from HttpResponse content read streams
  • In case of HTTP/3, embed QuicException as ProtocolException.InnerException
@antonfirsov
antonfirsov / install-liburing.sh
Last active January 26, 2022 00:49
Patch Ubuntu 18.04 LTS for io_uring
mkdir liburing
pushd liburing
git clone https://github.com/axboe/liburing.git
pushd liburing
./configure
make
sudo make install
popd
@antonfirsov
antonfirsov / GCMemoryInfoMinimalRepro.csproj
Last active July 8, 2021 11:37
GCMemoryInfoMinimalRepro
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
</Project>
public class _ExhaustTest : IDisposable
{
public const int ListenerCount = 1000;
public const int ConnectCount = 1024 * 20;
//public const int ConnectCount = 10;
private readonly ITestOutputHelper _output;
private Task[] _listenTasks = new Task[ListenerCount];
private Socket[] _listeners = new Socket[ListenerCount];
@antonfirsov
antonfirsov / Type1.txt
Created March 22, 2021 15:34
HTTP Stress failures
2021-03-18T15:01:04.4504783Z client_1 | System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (server:5001)
2021-03-18T15:01:04.4506315Z
2021-03-18T15:01:04.4508672Z client_1 | ---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2021-03-18T15:01:04.4509920Z
2021-03-18T15:01:04.4511533Z client_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs:line 1233
2021-03-18T15:01:04.4512995Z
2021-03-18T15:01:04.4514290Z client_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.
@antonfirsov
antonfirsov / Backend Utility Class.cs
Created March 18, 2021 14:51
ImageSharp-1577-Repro
public static void TransformImage(ImageEditModel imageEdit, MemoryStream destinationStream)
{
if (destinationStream == null)
{
throw new ArgumentNullException(nameof(destinationStream));
}
var sourceImage = Image.Load(imageEdit.SourceStream);
var blur = imageEdit.History.Where(h => h.Tool == ImageTool.Blur).FirstOrDefault();
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using System;
using SixLabors.ImageSharp.PixelFormats;
namespace ColonTest
{
class Program