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 UDPMux map lookups #659

Merged
merged 1 commit into from
Mar 25, 2024
Merged

Conversation

potaga
Copy link

@potaga potaga commented Mar 25, 2024

Description

UDPMux is using a map to lookup addresses of each packets. Unfortunately the key is based on a string and each time we want to check the map, a conversion of the UDP address to string is made (.String()) which is expensive.
This CR replace the string key by a binary key called ipPort. This structure contains a netip.Addr field and ipPort could be used as a map key

@potaga potaga changed the title Replace map[string] by map[ipPort] Improve performance of UDPMux map lookups Mar 25, 2024
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 57.50000% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 78.42%. Comparing base (52f2075) to head (430a9a0).

Files Patch % Lines
udp_mux.go 62.50% 5 Missing and 4 partials ⚠️
udp_muxed_conn.go 50.00% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #659      +/-   ##
==========================================
- Coverage   78.69%   78.42%   -0.27%     
==========================================
  Files          42       42              
  Lines        4464     4487      +23     
==========================================
+ Hits         3513     3519       +6     
- Misses        733      745      +12     
- Partials      218      223       +5     
Flag Coverage Δ
go 78.42% <57.50%> (-0.27%) ⬇️
wasm 23.71% <0.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

UDPMux is using a map to lookup addresses of each packets.
Unfortunately the key is based on a string and each time we
want to check the map, a conversion of the UDP address to string
is made (.String()) which is expensive.

This CR replace the string key by a binary key called ipPort. This
structure contains a netip.Addr field and ipPort could be used as
a map key
@Sean-Der Sean-Der merged commit 66051b6 into pion:master Mar 25, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants