Skip to content

perf: keep sse.Register and convenience generic parts small - #1117

Merged
wolveix merged 1 commit into
mainfrom
generic-shims-sse-convenience
Sep 24, 2026
Merged

wolveix merged 1 commit into
mainfrom
generic-shims-sse-convenience

Conversation

@wolveix

@wolveix wolveix commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #1115. Go compiles a separate copy of a generic function body for each distinct type layout, so the remaining per-operation generics still duplicated code that never touches their type parameters.

  • sse.Register[I]: schema building moved into addEventStreamResponse, response streaming into streamResponse, and stream is no longer generic (it takes a run(ctx, send) closure). Only the huma.Register call and the closure over input/f remain generic.
  • convenience[I, O] (behind huma.Get, Post, etc.): operation building moved into convenienceOperation. The typed nil *O is still passed through for the ID/summary generators and _convenience_*_out metadata used by groups.

No public API or behaviour changes.

Numbers

Probe program with 20 huma.Get + 20 sse.Register operations, each with distinct types:

main this PR
generic code per op pair 9,104 B 2,384 B
binary size 8,394,162 B 8,190,306 B

Roughly 5.7 KB saved per SSE operation and 1 KB per convenience operation. The remainder is mostly the Register shim from #1115.

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.18%. Comparing base (e4a9e0c) to head (2a6a498).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1117      +/-   ##
==========================================
+ Coverage   93.17%   93.18%   +0.01%     
==========================================
  Files          24       24              
  Lines        4997     5005       +8     
==========================================
+ Hits         4656     4664       +8     
  Misses        273      273              
  Partials       68       68              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wolveix
wolveix merged commit 679c4d0 into main Sep 24, 2026
7 checks passed
@wolveix
wolveix deleted the generic-shims-sse-convenience branch September 24, 2026 18:46
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.

1 participant