Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/package-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: Push the packed NuGet to NuGet.org
type: boolean
default: false
workflow_call: # called by release.yml to publish alongside the other packages
inputs:
publish:
type: boolean
default: false
push:
tags:
- 'native-v*'
Expand Down Expand Up @@ -111,20 +116,23 @@ jobs:

- name: Resolve package version
id: ver
# native-vX.Y.Z tag -> X.Y.Z (a release); otherwise a CI prerelease.
# tag native-vX.Y.Z -> X.Y.Z; publish (dispatch/release call) -> the csproj <Version>;
# PR smoke test -> a throwaway CI prerelease.
run: |
ref='${{ github.ref }}'
if [[ "$ref" == refs/tags/native-v* ]]; then
echo "version=${ref#refs/tags/native-v}" >> "$GITHUB_OUTPUT"
echo "args=-p:Version=${ref#refs/tags/native-v}" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.publish }}" == "true" ]]; then
echo "args=" >> "$GITHUB_OUTPUT"
else
echo "version=0.1.0-ci.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
echo "args=-p:Version=0.0.0-ci.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
fi

- name: Pack
run: >
dotnet pack bindings/dotnet/Glyph11.Native/Glyph11.Native.csproj
-c Release -p:ContinuousIntegrationBuild=true
-p:Version=${{ steps.ver.outputs.version }}
${{ steps.ver.outputs.args }}
-o artifacts

- name: Upload package
Expand All @@ -140,7 +148,7 @@ jobs:
name: Publish to NuGet.org
needs: pack
# Only on a native-v* tag, or an explicit dispatch with publish=true.
if: startsWith(github.ref, 'refs/tags/native-v') || (github.event_name == 'workflow_dispatch' && inputs.publish)
if: startsWith(github.ref, 'refs/tags/native-v') || ((github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.publish)
runs-on: ubuntu-latest
environment:
name: production
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/package-pico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: Push the packed NuGet to NuGet.org
type: boolean
default: false
workflow_call: # called by release.yml to publish alongside the other packages
inputs:
publish:
type: boolean
default: false
push:
tags:
- 'pico-v*'
Expand Down Expand Up @@ -111,20 +116,23 @@ jobs:

- name: Resolve package version
id: ver
# pico-vX.Y.Z tag -> X.Y.Z (a release); otherwise a CI prerelease.
# tag pico-vX.Y.Z -> X.Y.Z; publish (dispatch/release call) -> the csproj <Version>;
# PR smoke test -> a throwaway CI prerelease.
run: |
ref='${{ github.ref }}'
if [[ "$ref" == refs/tags/pico-v* ]]; then
echo "version=${ref#refs/tags/pico-v}" >> "$GITHUB_OUTPUT"
echo "args=-p:Version=${ref#refs/tags/pico-v}" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.publish }}" == "true" ]]; then
echo "args=" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.1-ci.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
echo "args=-p:Version=0.0.1-ci.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
fi

- name: Pack
run: >
dotnet pack bindings/dotnet/Glyph11.Pico/Glyph11.Pico.csproj
-c Release -p:ContinuousIntegrationBuild=true
-p:Version=${{ steps.ver.outputs.version }}
${{ steps.ver.outputs.args }}
-o artifacts

- name: Upload package
Expand All @@ -140,7 +148,7 @@ jobs:
name: Publish to NuGet.org
needs: pack
# Only on a pico-v* tag, or an explicit dispatch with publish=true.
if: startsWith(github.ref, 'refs/tags/pico-v') || (github.event_name == 'workflow_dispatch' && inputs.publish)
if: startsWith(github.ref, 'refs/tags/pico-v') || ((github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') && inputs.publish)
runs-on: ubuntu-latest
environment:
name: production
Expand Down
32 changes: 23 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Release

# Publishes all three NuGet packages at their csproj versions:
# Glyph11 (managed) here, and Glyph11.Native / Glyph11.Pico via their package
# workflows (which run the full native build matrices, then pack + push).
# Every push uses --skip-duplicate, so re-running only publishes versions not yet
# on NuGet.org — bump a package's <Version> and re-run to release it.
on:
workflow_dispatch:

Expand All @@ -9,15 +14,11 @@ permissions:

jobs:

publish:

name: Build & Publish Packages

managed:
name: Glyph11 (managed)
runs-on: windows-latest

environment:
name: production

steps:
- name: Checkout source
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
Expand All @@ -32,9 +33,6 @@ jobs:
9.0
10.0

- name: Setup NuGet CLI
uses: NuGet/setup-nuget@323ab0502cd38fdc493335025a96c8fdb0edc71f # v2

- name: Restore dependencies
run: dotnet restore
working-directory: src
Expand All @@ -56,3 +54,19 @@ jobs:
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push *.nupkg -k "$env:NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate

# Build the 6-RID native matrix, pack, and publish Glyph11.Native at its csproj version.
native:
name: Glyph11.Native
uses: ./.github/workflows/package-native.yml
with:
publish: true
secrets: inherit

# Build the 6-RID native matrix, pack, and publish Glyph11.Pico at its csproj version.
pico:
name: Glyph11.Pico
uses: ./.github/workflows/package-pico.yml
with:
publish: true
secrets: inherit
2 changes: 1 addition & 1 deletion Benchmarks/BenchmarkData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static byte[] BuildSmallHeader()
"GET /route?p1=1&p2=2&p3=3&p4=4 HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Content-Length: 100\r\n" +
"Server: GenHTTP\r\n\r\n");
"Server: Glyph11\r\n\r\n");
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\src\Examples\GenHTTP\GenHTTP.csproj" />
<ProjectReference Include="..\src\Glyph11\Glyph11.csproj" />
</ItemGroup>

Expand Down
32 changes: 16 additions & 16 deletions Benchmarks/FlexibleParserBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Running;
using GenHTTP.Types;
using Glyph11.Parser.FlexibleParser;
using Glyph11.Protocol;

namespace Benchmarks;

Expand Down Expand Up @@ -40,14 +40,14 @@ public static void Main(string[] args)
[MemoryDiagnoser]
public class FlexibleParserBenchmark
{
private readonly Request _into = new();
private readonly BinaryRequest _into = new();

// ---- Small (~80B) ----

private readonly ReadOnlySequence<byte> _buffer =
new(("GET /route?p1=1&p2=2&p3=3&p4=4 HTTP/1.1\r\n"u8 +
"Content-Length: 100\r\n"u8 +
"Server: GenHTTP\r\n\r\n"u8).ToArray());
"Server: Glyph11\r\n\r\n"u8).ToArray());

private ReadOnlySequence<byte> _segmentedBuffer = CreateMultiSegment();

Expand Down Expand Up @@ -79,7 +79,7 @@ private static ReadOnlySequence<byte> CreateMultiSegment()
{
var seg1 = "GET /route?p1=1&p2=2&p3=3&p4=4 HT"u8.ToArray();
var seg2 = "TP/1.1\r\nContent-Length: 100\r\nServer: "u8.ToArray();
var seg3 = "GenHTTP\r\n\r\n"u8.ToArray();
var seg3 = "Glyph11\r\n\r\n"u8.ToArray();

var first = new Glyph11.Utils.BufferSegment(seg1);
var last = first.Append(seg2).Append(seg3);
Expand All @@ -92,46 +92,46 @@ private static ReadOnlySequence<byte> CreateMultiSegment()
[Benchmark]
public void Small_ROM()
{
_into.Reset();
FlexibleParser.TryExtractFullHeaderReadOnlyMemory(ref _memory, _into.Source, out _);
_into.Clear();
FlexibleParser.TryExtractFullHeaderReadOnlyMemory(ref _memory, _into, out _);
}

[Benchmark]
public void Small_MultiSegment()
{
_into.Reset();
FlexibleParser.TryExtractFullHeader(ref _segmentedBuffer, _into.Source, out _);
_into.Clear();
FlexibleParser.TryExtractFullHeader(ref _segmentedBuffer, _into, out _);
}

// ---- 4KB ----

[Benchmark]
public void Header4K_ROM()
{
_into.Reset();
FlexibleParser.TryExtractFullHeaderReadOnlyMemory(ref _rom4K, _into.Source, out _);
_into.Clear();
FlexibleParser.TryExtractFullHeaderReadOnlyMemory(ref _rom4K, _into, out _);
}

[Benchmark]
public void Header4K_MultiSegment()
{
_into.Reset();
FlexibleParser.TryExtractFullHeader(ref _seg4K, _into.Source, out _);
_into.Clear();
FlexibleParser.TryExtractFullHeader(ref _seg4K, _into, out _);
}

// ---- 32KB ----

[Benchmark]
public void Header32K_ROM()
{
_into.Reset();
FlexibleParser.TryExtractFullHeaderReadOnlyMemory(ref _rom32K, _into.Source, out _);
_into.Clear();
FlexibleParser.TryExtractFullHeaderReadOnlyMemory(ref _rom32K, _into, out _);
}

[Benchmark]
public void Header32K_MultiSegment()
{
_into.Reset();
FlexibleParser.TryExtractFullHeader(ref _seg32K, _into.Source, out _);
_into.Clear();
FlexibleParser.TryExtractFullHeader(ref _seg32K, _into, out _);
}
}
32 changes: 16 additions & 16 deletions Benchmarks/UltraHardenedParserBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.Buffers;
using BenchmarkDotNet.Attributes;
using GenHTTP.Types;
using Glyph11.Parser;
using Glyph11.Parser.UltraHardened;
using Glyph11.Protocol;

namespace Benchmarks;

[MemoryDiagnoser]
public class UltraHardenedParserBenchmark
{
private readonly Request _into = new();
private readonly BinaryRequest _into = new();

private static readonly ParserLimits Limits = ParserLimits.Default with { MaxTotalHeaderBytes = 64 * 1024, MaxHeaderCount = 200 };

Expand All @@ -19,7 +19,7 @@ public class UltraHardenedParserBenchmark
new(("GET /route?p1=1&p2=2&p3=3&p4=4 HTTP/1.1\r\n"u8 +
"Host: localhost\r\n"u8 +
"Content-Length: 100\r\n"u8 +
"Server: GenHTTP\r\n\r\n"u8).ToArray());
"Server: Glyph11\r\n\r\n"u8).ToArray());

private ReadOnlySequence<byte> _segmentedBuffer = CreateMultiSegment();

Expand Down Expand Up @@ -51,7 +51,7 @@ private static ReadOnlySequence<byte> CreateMultiSegment()
{
var seg1 = "GET /route?p1=1&p2=2&p3=3&p4=4 HT"u8.ToArray();
var seg2 = "TP/1.1\r\nHost: localhost\r\nContent-Length: 100\r\nServer: "u8.ToArray();
var seg3 = "GenHTTP\r\n\r\n"u8.ToArray();
var seg3 = "Glyph11\r\n\r\n"u8.ToArray();

var first = new Glyph11.Utils.BufferSegment(seg1);
var last = first.Append(seg2).Append(seg3);
Expand All @@ -64,46 +64,46 @@ private static ReadOnlySequence<byte> CreateMultiSegment()
[Benchmark]
public void Small_ROM()
{
_into.Reset();
UltraHardenedParser.TryExtractFullHeaderROM(ref _memory, _into.Source, in Limits, out _);
_into.Clear();
UltraHardenedParser.TryExtractFullHeaderROM(ref _memory, _into, in Limits, out _);
}

[Benchmark]
public void Small_MultiSegment()
{
_into.Reset();
UltraHardenedParser.TryExtractFullHeaderValidated(ref _segmentedBuffer, _into.Source, in Limits, out _);
_into.Clear();
UltraHardenedParser.TryExtractFullHeaderValidated(ref _segmentedBuffer, _into, in Limits, out _);
}

// ---- 4KB ----

[Benchmark]
public void Header4K_ROM()
{
_into.Reset();
UltraHardenedParser.TryExtractFullHeaderROM(ref _rom4K, _into.Source, in Limits, out _);
_into.Clear();
UltraHardenedParser.TryExtractFullHeaderROM(ref _rom4K, _into, in Limits, out _);
}

[Benchmark]
public void Header4K_MultiSegment()
{
_into.Reset();
UltraHardenedParser.TryExtractFullHeaderValidated(ref _seg4K, _into.Source, in Limits, out _);
_into.Clear();
UltraHardenedParser.TryExtractFullHeaderValidated(ref _seg4K, _into, in Limits, out _);
}

// ---- 32KB ----

[Benchmark]
public void Header32K_ROM()
{
_into.Reset();
UltraHardenedParser.TryExtractFullHeaderROM(ref _rom32K, _into.Source, in Limits, out _);
_into.Clear();
UltraHardenedParser.TryExtractFullHeaderROM(ref _rom32K, _into, in Limits, out _);
}

[Benchmark]
public void Header32K_MultiSegment()
{
_into.Reset();
UltraHardenedParser.TryExtractFullHeaderValidated(ref _seg32K, _into.Source, in Limits, out _);
_into.Clear();
UltraHardenedParser.TryExtractFullHeaderValidated(ref _seg32K, _into, in Limits, out _);
}
}
17 changes: 17 additions & 0 deletions Examples/Glyph11.Example/Glyph11.Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable> <!-- a sample app — never publish it as a NuGet -->
<IsPublishable>false</IsPublishable>
</PropertyGroup>

<ItemGroup>
<!-- In a real app this is: <PackageReference Include="Glyph11" Version="0.3.5" /> -->
<ProjectReference Include="..\..\src\Glyph11\Glyph11.csproj" />
</ItemGroup>

</Project>
Loading
Loading