Skip to content

Instantly share code, notes, and snippets.

:octocat:
Catching up on things

David Fowler davidfowl

View GitHub Profile
@davidfowl
davidfowl / FormReaderExtensions.cs
Last active Mar 15, 2019
FormReader prototype
View FormReaderExtensions.cs
public static class FormReaderExtensions
{
public static async ValueTask<IFormCollection> ReadFormAsync2(this HttpRequest request)
{
var reader = request.BodyPipe;
KeyValueAccumulator accumulator = default;
while (true)
{
var result = await reader.ReadAsync();
View deps.json
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.0",
"signature": "22c69940c9b25639e4f75123b23a701826ae1b1a"
},
"compilationOptions": {
"defines": [
"TRACE",
"DEBUG",
"NETCOREAPP",
View ResponseCachingPlaintextCachedDelete.txt
This file has been truncated, but you can view the full file.
[12:04:42.659] Using worker Wrk
[12:04:42.754] Running session '92c5e28c8dec4dab902cd1ff12ccaf9d' with description ''
[12:04:42.754] Starting scenario ResponseCachingPlaintextCachedDelete on benchmark server...
[12:04:42.837] Fetching job: http://10.195.201.248:5001/jobs/31
[12:04:42.917] Job submitted, waiting...
[12:05:16.053] Starting scenario ResponseCachingPlaintextCachedDelete on benchmark client...
[12:05:16.488] Client Job ready: http://10.195.202.5:5002/jobs/1
[12:05:18.654] Scenario ResponseCachingPlaintextCachedDelete completed on benchmark client
[12:05:18.655] Deleting scenario ResponseCachingPlaintextCachedDelete on benchmark client...
@davidfowl
davidfowl / MemoryLeak.cs
Last active Jan 19, 2019
Leaking tasks
View MemoryLeak.cs
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp19
{
class Program
{
private static Dictionary<string, Task<string>> _cache = new Dictionary<string, Task<string>>();
View Multitenancy.cs
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
/*
- Don't need to support different services per tenant.
- Tenant services lifetime outlasts the request.
View simpler.cs
using System;
using System.Collections.Generic;
using System.Threading;
namespace TimersAreWeird
{
public class Program
{
public static void Main(string[] args)
{
View perf.md

ReadOnlySequence.Slice + Span

             Method |          Input | HubProtocol |      Mean |     Error |    StdDev |      Op/s |  Gen 0 | Allocated |
------------------ |--------------- |------------ |----------:|----------:|----------:|----------:|-------:|----------:|
 ReadSingleMessage |   FewArguments |        Json |  2.459 us | 0.0491 us | 0.1295 us | 406,692.8 | 0.0305 |     960 B |
 ReadSingleMessage | LargeArguments |        Json | 90.188 us | 2.1015 us | 6.0296 us |  11,087.9 | 1.9531 |   58840 B |
 ReadSingleMessage |  ManyArguments |        Json |  4.403 us | 0.0922 us | 0.2063 us | 227,115.5 | 0.0458 |    1504 B |
 ReadSingleMessage |    NoArguments |        Json |  1.194 us | 0.0249 us | 0.0449 us | 837,771.3 | 0.0172 |     584 B |
View HeaderPropagationV2.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Threading;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace header_propagation
View Pipelineversion.cs
using System;
using System.Buffers;
using System.Buffers.Text;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Text;
using System.Threading.Tasks;
namespace perf_demo
@davidfowl
davidfowl / AUsage.cs
Last active Mar 1, 2019
Header propagation HttpClientFactory middleware
View AUsage.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("myclient");
// Global header propagation for any HttpClient that comes from HttpClientFactory
services.AddHeaderPropagation(options =>
{
options.HeaderNames.Add("Correlation-Id");
});
}
You can’t perform that action at this time.