Skip to content

perf: optimize Echo dispatch and add reproducible benchmarks#5

Merged
cmilesio merged 8 commits into
mainfrom
feat/reproducible-framework-benchmarks
Jul 18, 2026
Merged

perf: optimize Echo dispatch and add reproducible benchmarks#5
cmilesio merged 8 commits into
mainfrom
feat/reproducible-framework-benchmarks

Conversation

@cmilesio

Copy link
Copy Markdown
Member

What

  • Replace per-request Echo adapter allocation with a zero-allocation native context view, dispatch Web routes from Echo's resolved route, and compile middleware chains once while preserving late root middleware registration.
  • Rework timeout handling around detached request ownership and a buffered response so completion, expiry, cancellation, and panic have one authoritative winner.
  • Run WebSocket middleware before upgrade so middleware can reject a handshake before 101 Switching Protocols.
  • Add a reproducible comparison with net/http, Echo, Gin, Chi, Gorilla Mux, and httprouter, including raw samples, a deterministic SVG, methodology, source provenance, and CI verification.

Why

The Echo path had avoidable adapter allocations and middleware reconstruction on hot requests, while timeout work could outlive ownership of a pooled request context. Fixing those issues restores competitive performance and makes cancellation behavior deterministic.

The benchmark records seven rotated single-core samples with environment and dependency metadata. CI verifies source currentness and deterministic rendering instead of comparing machine-dependent performance or enforcing rankings.

Compatibility

Source/API, configuration, persisted-data, and minimum-Go-version compatibility are preserved. Runtime behavior changes intentionally: middleware constructors run once at registration, WebSocket middleware can reject before upgrade, and state crossing a timeout boundary must use web.Context.Set/Get rather than the native Echo store.

Validation

  • Root, docs, and examples tests and vet pass, including GOWORK=off nested-module validation.
  • Root and docs race suites and strict checkptr validation pass.
  • Module files are tidy, README generation is idempotent, and make benchmark-svg-verify passes twice with identical artifact hashes.

@codecov-commenter

codecov-commenter commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.38744% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
adapter/echoweb/context.go 98.86% 0 Missing and 3 partials ⚠️
adapter/echoweb/router.go 99.51% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cmilesio
cmilesio merged commit d0005de into main Jul 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants