Skip to content

Resource optimizations, Go 1.25, remove IDNA library, add benchmark CI#973

Merged
wolveix merged 6 commits into
mainfrom
optimizations
Feb 19, 2026
Merged

Resource optimizations, Go 1.25, remove IDNA library, add benchmark CI#973
wolveix merged 6 commits into
mainfrom
optimizations

Conversation

@wolveix

@wolveix wolveix commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

This PR:

  • Adds a benchmark step to the pull request CI + added many benchmark functions
  • Fixes form data memory leak (Memory leak while using huma.MultipartFormFiles[T] #902)
  • Removes IDNA external library and therefore idn-hostname format support (aliased to hostname format support for the time being)
  • Upgrades Huma to Go 1.25 + ran go fix (since 1.26 released last week, 1.25 is the lowest supported version)
  • Various library optimizations:

Notable improvements

Benchmark Time Memory Allocs
DefaultSchemaNamer -38.6% -76.9% (184→104 B) -42.9% (7→4)
PathBuffer/PushIndex -56.2% 8→0 B 2→0
PathBuffer/Push -4.0% 0% 0%
SchemaGeneration/ReusedRegistry -21.6% -4.2% -12.8%
SchemaGeneration/RegistryLookup -14.5% -16.4% -16.7%
Raw results
==> Comparison (A=new vs B=old):
goos: darwin
goarch: arm64
pkg: github.com/danielgtaylor/huma/v2
cpu: Apple M3 Pro
                                   │ /tmp/bench_a.txt │           /tmp/bench_b.txt           │
                                   │      sec/op      │    sec/op     vs base                │
DefaultSchemaNamer-12                    246.2n ±  4%   341.3n ± 16%  +38.60% (p=0.000 n=10)
PathBuffer/Push-12                       10.05n ±  5%   10.45n ±  6%   +3.98% (p=0.003 n=10)
PathBuffer/PushIndex-12                  28.33n ±  2%   44.25n ±  7%  +56.22% (p=0.000 n=10)
PathBuffer/Mixed-12                      23.57n ±  5%   22.37n ±  3%   -5.11% (p=0.001 n=10)
SchemaGeneration/NewRegistry-12          50.43µ ±  8%   49.28µ ±  2%   -2.28% (p=0.023 n=10)
SchemaGeneration/ReusedRegistry-12       28.29µ ± 17%   22.17µ ±  3%  -21.62% (p=0.000 n=10)
SchemaGeneration/RegistryLookup-12       239.1n ±  8%   273.6n ±  3%  +14.45% (p=0.001 n=10)
Validate_Complex-12                      1.759µ ±  2%   1.766µ ±  1%        ~ (p=0.517 n=10)
Register-12                              16.99µ ± 13%   17.21µ ±  3%        ~ (p=0.971 n=10)
FullRequest_Complex-12                   10.85µ ± 20%   10.91µ ±  6%        ~ (p=0.796 n=10)
geomean                                  843.7n         900.3n         +6.71%

                                   │ /tmp/bench_a.txt │            /tmp/bench_b.txt            │
                                   │       B/op       │     B/op      vs base                  │
DefaultSchemaNamer-12                    104.0 ± 0%       184.0 ± 0%  +76.92% (p=0.000 n=10)
PathBuffer/Push-12                       0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
PathBuffer/PushIndex-12                  0.000 ± 0%       8.000 ± 0%        ? (p=0.000 n=10)
PathBuffer/Mixed-12                      0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
SchemaGeneration/NewRegistry-12        61.41Ki ± 0%     63.82Ki ± 0%   +3.93% (p=0.000 n=10)
SchemaGeneration/ReusedRegistry-12     27.11Ki ± 0%     28.23Ki ± 0%   +4.15% (p=0.000 n=10)
SchemaGeneration/RegistryLookup-12       856.0 ± 0%      1024.0 ± 0%  +19.63% (p=0.000 n=10)
Validate_Complex-12                      0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
Register-12                            14.41Ki ± 0%     14.77Ki ± 0%   +2.52% (p=0.000 n=10)
FullRequest_Complex-12                 11.90Ki ± 0%     11.91Ki ± 0%   +0.13% (p=0.000 n=10)
geomean                                             ²                 ?                      ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                   │ /tmp/bench_a.txt │           /tmp/bench_b.txt           │
                                   │    allocs/op     │ allocs/op   vs base                  │
DefaultSchemaNamer-12                    4.000 ± 0%     7.000 ± 0%  +75.00% (p=0.000 n=10)
PathBuffer/Push-12                       0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
PathBuffer/PushIndex-12                  0.000 ± 0%     2.000 ± 0%        ? (p=0.000 n=10)
PathBuffer/Mixed-12                      0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
SchemaGeneration/NewRegistry-12          765.0 ± 0%     865.0 ± 0%  +13.07% (p=0.000 n=10)
SchemaGeneration/ReusedRegistry-12       345.0 ± 0%     389.0 ± 0%  +12.75% (p=0.000 n=10)
SchemaGeneration/RegistryLookup-12       5.000 ± 0%     6.000 ± 0%  +20.00% (p=0.000 n=10)
Validate_Complex-12                      0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Register-12                              222.0 ± 0%     249.0 ± 0%  +12.16% (p=0.000 n=10)
FullRequest_Complex-12                   115.0 ± 0%     116.0 ± 0%   +0.87% (p=0.000 n=10)
geomean                                             ²               ?                      ²
¹ all samples are equal
² summaries must be >0 to compute geomean

Bump Go version to 1.25, add benchmarks, optimize parameters and input handling, and fix memory allocation leaks
@codecov

codecov Bot commented Feb 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.24138% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.11%. Comparing base (ddbb810) to head (237cd19).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
huma.go 96.36% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #973      +/-   ##
==========================================
- Coverage   93.17%   93.11%   -0.06%     
==========================================
  Files          23       23              
  Lines        4715     4736      +21     
==========================================
+ Hits         4393     4410      +17     
- Misses        266      268       +2     
- Partials       56       58       +2     

☔ View full report in Codecov by Sentry.
📢 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.

@leonklingele leonklingele left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment thread README_JA.md
Comment thread validate.go
Comment thread go.mod
@wolveix
wolveix merged commit e31a819 into main Feb 19, 2026
5 checks passed
@wolveix
wolveix deleted the optimizations branch February 19, 2026 00:20

@leonklingele leonklingele left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :shipit:

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