Skip to content

Instantly share code, notes, and snippets.

:octocat:
Catching up on things

David Fowler davidfowl

:octocat:
Catching up on things
Block or report user

Report or block davidfowl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DuplexPipe.cs
public class DuplexPipe<TStream> : Stream, IDuplexPipe where TStream : Stream
{
private readonly IDuplexPipe _duplexPipe;
public DuplexPipe(IDuplexPipe duplexPipe, Func<Stream, TStream> wrapper)
{
_duplexPipe = duplexPipe;
Stream = wrapper(this);
Input = PipeReader.Create(Stream);
@davidfowl
davidfowl / bedrock-server.cs
Last active May 29, 2019
A sample of the current API usage with bedrock's listener layer
View bedrock-server.cs
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
@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
You can’t perform that action at this time.