[PR #75] perf: optimize SNI ClientHello parsing #257

Open
opened 2026-04-27 18:11:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/gerbil/pull/75
Author: @LaurenceJJones
Created: 4/9/2026
Status: 🔄 Open

Base: devHead: investigate/sni-cpu-upstream-dev


📝 Commits (1)

  • 3377bc6 optimize SNI ClientHello parsing + add regression coverage

📊 Changes

2 files changed (+614 additions, -41 deletions)

View changed files

📝 proxy/proxy.go (+146 -41)
📝 proxy/proxy_test.go (+468 -0)

📄 Description

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Move SNI extraction from TLS handshake to direct ClientHello parsing. Keeps forwarding behavior and hostname normalization compatibility. Adds parity + malformed-input tests and broader fixture benchmarks.

Benchmark summary (linux/amd64, i7-12700H)

case new (ns/op) old (ns/op) speedup new allocs old allocs
short direct 8193 133580 16.3x 11 76
short fragmented 8674 136008 15.7x 12 77
typical direct 7418 137054 18.5x 11 76
typical fragmented 8252 149462 18.1x 12 77
mixed_case direct 7934 142533 18.0x 12 76
mixed_case fragmented 7690 138264 18.0x 13 77
long direct 7624 136663 17.9x 11 76
long fragmented 7733 143585 18.6x 12 77

Overall: ~16x-19x faster, ~85% fewer allocs/op.

How to test?

Internal SNI forwarding but ensured correctives within testing suite and performed benchmark tests to ensure it drives improvement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fosrl/gerbil/pull/75 **Author:** [@LaurenceJJones](https://github.com/LaurenceJJones) **Created:** 4/9/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `investigate/sni-cpu-upstream-dev` --- ### 📝 Commits (1) - [`3377bc6`](https://github.com/fosrl/gerbil/commit/3377bc6d767d859ccad28da26365e3d6fbe98f3e) optimize SNI ClientHello parsing + add regression coverage ### 📊 Changes **2 files changed** (+614 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `proxy/proxy.go` (+146 -41) 📝 `proxy/proxy_test.go` (+468 -0) </details> ### 📄 Description ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## Description Move SNI extraction from TLS handshake to direct ClientHello parsing. Keeps forwarding behavior and hostname normalization compatibility. Adds parity + malformed-input tests and broader fixture benchmarks. Benchmark summary (linux/amd64, i7-12700H) | case | new (ns/op) | old (ns/op) | speedup | new allocs | old allocs | |-------------------------|-------------|-------------|---------|------------|------------| | short direct | 8193 | 133580 | 16.3x | 11 | 76 | | short fragmented | 8674 | 136008 | 15.7x | 12 | 77 | | typical direct | 7418 | 137054 | 18.5x | 11 | 76 | | typical fragmented | 8252 | 149462 | 18.1x | 12 | 77 | | mixed_case direct | 7934 | 142533 | 18.0x | 12 | 76 | | mixed_case fragmented | 7690 | 138264 | 18.0x | 13 | 77 | | long direct | 7624 | 136663 | 17.9x | 11 | 76 | | long fragmented | 7733 | 143585 | 18.6x | 12 | 77 | Overall: ~16x-19x faster, ~85% fewer allocs/op. ## How to test? Internal SNI forwarding but ensured correctives within testing suite and performed benchmark tests to ensure it drives improvement. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-27 18:11:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gerbil#257