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 performance of dependency management - avoid linear search. #22

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

ioquatix
Copy link
Member

@ioquatix ioquatix commented Nov 9, 2024

It turns out that a linear search is bad when dealing with a lot of concurrent streams (doh). Use a binary search for insertion of weighted streams, and defer removal until consume_window is invoked for deletion.

Before:

> h2load -n 10000 -c 1 -m 100 https://localhost:9292/
starting benchmark...
spawning thread #0: 1 total client(s). 10000 total requests
TLS Protocol: TLSv1.3
Cipher: TLS_AES_128_GCM_SHA256
Server Temp Key: ECDH prime256v1 256 bits
Application protocol: h2
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done

finished in 1.21s, 8269.18 req/s, 331.14KB/s
requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 400.45KB (410057) total, 29.31KB (30015) headers (space savings 93.33%), 107.42KB (110000) data
                     min         max         mean         sd        +/- sd
time for request:     4.27ms     20.76ms     12.04ms       688us    96.23%
time for connect:     1.95ms      1.95ms      1.95ms         0us   100.00%
time to 1st byte:     6.19ms      6.19ms      6.19ms         0us   100.00%
req/s           :    8271.77     8271.77     8271.77        0.00   100.00%

After:

finished in 993.23ms, 10068.17 req/s, 403.18KB/s
requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 400.45KB (410057) total, 29.31KB (30015) headers (space savings 93.33%), 107.42KB (110000) data
                     min         max         mean         sd        +/- sd
time for request:     2.42ms     13.04ms      9.89ms       452us    96.97%
time for connect:     1.22ms      1.22ms      1.22ms         0us   100.00%
time to 1st byte:     3.64ms      3.64ms      3.64ms         0us   100.00%
req/s           :   10071.85    10071.85    10071.85        0.00   100.00%

Thanks @tenderlove for pointing this out!

Types of Changes

  • Performance improvement.

Contribution

@ioquatix ioquatix force-pushed the dependency-performance-improvements branch from e2ea7c6 to 0b3bdc4 Compare November 9, 2024 22:23
@ioquatix ioquatix force-pushed the dependency-performance-improvements branch from 0b3bdc4 to a839e29 Compare November 9, 2024 22:49
@ioquatix ioquatix merged commit 41dda40 into main Nov 9, 2024
36 of 40 checks passed
@ioquatix ioquatix deleted the dependency-performance-improvements branch November 9, 2024 22:54
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