HTTP.jl icon indicating copy to clipboard operation
HTTP.jl copied to clipboard

Reduce slightly allocations when reading/writing HTTP messages

Open nickrobinson251 opened this issue 3 years ago • 2 comments

  1. write direct to io rather than first creating strings
    • we need to be careful to string any numbers before doing this, but doing this selectively still reduces allocations
  2. don't create a VersionNumber every time we parse a message (in parse_status_line!/parse_request_line!), as the VersionNumber constructor relies on regex matching which allocates, instead we can define out own much simpler type with allocation-free parsing

Together this takes a simple GET request from 170 -> 155 allocations

nickrobinson251 avatar Oct 31 '22 17:10 nickrobinson251

Codecov Report

Merging #950 (2fe988b) into master (7a54ffc) will decrease coverage by 0.62%. The diff coverage is 85.93%.

:exclamation: Current head 2fe988b differs from pull request most recent head d59f8ae. Consider uploading reports for the commit d59f8ae to get more accurate results

@@            Coverage Diff             @@
##           master     #950      +/-   ##
==========================================
- Coverage   79.85%   79.23%   -0.63%     
==========================================
  Files          36       36              
  Lines        2969     3010      +41     
==========================================
+ Hits         2371     2385      +14     
- Misses        598      625      +27     
Impacted Files Coverage Δ
src/ConnectionPool.jl 85.40% <ø> (-0.86%) :arrow_down:
src/Servers.jl 79.47% <0.00%> (ø)
src/Strings.jl 90.24% <79.48%> (-9.76%) :arrow_down:
src/Messages.jl 86.04% <100.00%> (+0.08%) :arrow_up:
src/Parsers.jl 97.29% <100.00%> (ø)
src/Streams.jl 93.75% <100.00%> (-1.14%) :arrow_down:
src/clientlayers/MessageRequest.jl 92.30% <100.00%> (ø)
src/access_log.jl 80.00% <0.00%> (-13.34%) :arrow_down:
src/Exceptions.jl 91.89% <0.00%> (-2.71%) :arrow_down:
src/connectionpools.jl 70.70% <0.00%> (-2.03%) :arrow_down:
... and 6 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Oct 31 '22 18:10 codecov-commenter

tests pass locally. not sure if we want to resolve #951 and get a clean CI run before merging here?

nickrobinson251 avatar Nov 01 '22 10:11 nickrobinson251