Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HTTPHeader normalisation performance for large inputs #347

Merged
merged 1 commit into from
May 17, 2022

Conversation

glbrntt
Copy link
Contributor

@glbrntt glbrntt commented May 17, 2022

Motivation:

Header normalisation is expensive when the input headers contain a large
number of connection header values.

Modifications:

  • When the headers to normalise contain more than 32 connection header
    values use a set to provide constant time lookup, rather than linear.

Result:

Better perf for HTTPHeader normalisation with large connection header
value lists.

Motivation:

Header normalisation is expensive when the input headers contain a large
number of connection header values.

Modifications:

- When the headers to normalise contain more than 32 connection header
  values use a set to provide constant time lookup, rather than linear.

Result:

Better perf for HTTPHeader normalisation with large connection header
value lists.
@glbrntt glbrntt added the 🔨 semver/patch No public API change. label May 17, 2022
@glbrntt
Copy link
Contributor Author

glbrntt commented May 17, 2022

@swift-nio-bot test perf please

@swift-server-bot
Copy link

performance report

build id: 21

timestamp: Tue May 17 09:43:08 UTC 2022

results

nameminmaxmeanstd
1_conn_10k_reqs 1.6607459783554077 1.700727105140686 1.6850006937980653 0.01528078307876625
encode_100k_header_blocks_indexable 0.14468300342559814 0.14531099796295166 0.1451084017753601 0.00019574398671356246
encode_100k_header_blocks_nonindexable 0.33011603355407715 0.3314650058746338 0.3309402108192444 0.0004103333324755851
encode_100k_header_blocks_neverIndexed 0.3330259323120117 0.3353539705276489 0.33367558717727663 0.0006497830993229124
decode_100k_header_blocks_indexable 0.10497593879699707 0.10560905933380127 0.1053286075592041 0.000228500360129959
decode_100k_header_blocks_nonindexable 0.12923407554626465 0.1303880214691162 0.12971220016479493 0.00034571157010218476
decode_100k_header_blocks_neverIndexed 0.1289670467376709 0.12961196899414062 0.1293125033378601 0.0002540544436384093
hpackheaders_canonical_form 0.030851006507873535 0.03143799304962158 0.031002700328826904 0.00021552581119081013
hpackheaders_canonical_form_trimming_whitespace 0.040794968605041504 0.04140293598175049 0.04097169637680054 0.00021835044364994555
hpackheaders_canonical_form_trimming_whitespace_short_strings 0.03802001476287842 0.03951394557952881 0.03843930959701538 0.00043811663799079366
hpackheaders_canonical_form_trimming_whitespace_long_strings 0.04514908790588379 0.04574394226074219 0.04535740613937378 0.0002535848025536832
hpackheaders_normalize_httpheaders_removing_10k_conn_headers 0.05470395088195801 0.0552980899810791 0.0549164891242981 0.00021631257253239196
hpackheaders_normalize_httpheaders_keeping_10k_conn_headers 0.03927600383758545 0.03979194164276123 0.03942561149597168 0.00017836633929544692
huffman_encode_basic 0.7919390201568604 0.8101199865341187 0.7946073889732361 0.005608274018308786
huffman_encode_complex 0.5319410562515259 0.5357859134674072 0.5328487038612366 0.0012002314451067637
huffman_decode_basic 0.057235002517700195 0.05780899524688721 0.057450401782989505 0.00020809817280214294
huffman_decode_complex 0.04532897472381592 0.04599606990814209 0.04555720090866089 0.00022831002950002882
server_only_10k_requests_1_concurrent 0.3517889976501465 0.35248804092407227 0.3521202802658081 0.0002654268948074409
server_only_10k_requests_100_concurrent 0.28675997257232666 0.2875009775161743 0.2872292876243591 0.0002297801752170679
stream_teardown_10k_requests_100_concurrent 0.1527460813522339 0.15355408191680908 0.15320420265197754 0.00031405841619329346

comparison

name current previous winner diff
1_conn_10k_reqs 1.6850006937980653 1.6798397064208985 previous 0%
encode_100k_header_blocks_indexable 0.1451084017753601 0.14162989854812622 previous 2%
encode_100k_header_blocks_nonindexable 0.3309402108192444 0.3299762964248657 previous 0%
encode_100k_header_blocks_neverIndexed 0.33367558717727663 0.3293057084083557 previous 1%
decode_100k_header_blocks_indexable 0.1053286075592041 0.10489749908447266 previous 0%
decode_100k_header_blocks_nonindexable 0.12971220016479493 0.13030190467834474 current 0%
decode_100k_header_blocks_neverIndexed 0.1293125033378601 0.13055150508880614 current 0%
hpackheaders_canonical_form 0.031002700328826904 0.03136119842529297 current -1%
hpackheaders_canonical_form_trimming_whitespace 0.04097169637680054 0.04263371229171753 current -3%
hpackheaders_canonical_form_trimming_whitespace_short_strings 0.03843930959701538 0.03957270383834839 current -3%
hpackheaders_canonical_form_trimming_whitespace_long_strings 0.04535740613937378 0.04882251024246216 current -7%
hpackheaders_normalize_httpheaders_removing_10k_conn_headers 0.0549164891242981 7.75164178609848 current -99%
hpackheaders_normalize_httpheaders_keeping_10k_conn_headers 0.03942561149597168 14.962627184391021 current -99%
huffman_encode_basic 0.7946073889732361 0.7547392010688782 previous 5%
huffman_encode_complex 0.5328487038612366 0.500220799446106 previous 6%
huffman_decode_basic 0.057450401782989505 0.05857760906219482 current -1%
huffman_decode_complex 0.04555720090866089 0.04356350898742676 previous 4%
server_only_10k_requests_1_concurrent 0.3521202802658081 0.3536600828170776 current 0%
server_only_10k_requests_100_concurrent 0.2872292876243591 0.28573299646377565 previous 0%
stream_teardown_10k_requests_100_concurrent 0.15320420265197754 0.15034650564193724 previous 1%

significant differences found

@glbrntt glbrntt requested a review from Lukasa May 17, 2022 09:45
@Lukasa
Copy link
Contributor

Lukasa commented May 17, 2022

Really nice change!

@Lukasa Lukasa merged commit 108ac15 into apple:main May 17, 2022
@glbrntt glbrntt deleted the gb-improve-header-normalisation-perf branch May 17, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants