elixir-mint / mint

Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2 🌱
Apache License 2.0
1.36k stars 112 forks source link

Optimize HTTP/2 request creation #423

Closed the-mikedavis closed 8 months ago

the-mikedavis commented 8 months ago

There is some low-hanging fruit to improve the time it takes to open a new request with HTTP/2 by avoiding URI.default_port/1 and String.upcase/1 calls.

With some very un-scientific :timer.tc/1 benchmarking I see these changes reduce the time it takes to complete a Mint.HTTP2.request/5 call (passing :stream as the data argument) from 12.8ms to 2.5ms.

coveralls commented 8 months ago

Pull Request Test Coverage Report for Build 7bb2e5bf376de14cf298d262e723658c7c60747f-PR-423


Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/mint/http2.ex 7 8 87.5%
<!-- Total: 7 8 87.5% -->
Totals Coverage Status
Change from base Build 321c8303ed626452c8b010b605950ec62e23e7e2: 87.5%
Covered Lines: 1251
Relevant Lines: 1429

💛 - Coveralls
whatyouhide commented 8 months ago

Ah this is fantastic, thanks for the benchmarks @the-mikedavis 💟