pion / ice

A Go implementation of ICE
https://pion.ly/
MIT License
424 stars 158 forks source link

Improve performance of UDPMux map lookups #659

Closed potaga closed 5 months ago

potaga commented 5 months ago

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

codecov[bot] commented 5 months ago

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 :warning:
udp_muxed_conn.go 50.00% 6 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/pion/ice/pull/659/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | Coverage Δ | | |---|---|---| | [go](https://app.codecov.io/gh/pion/ice/pull/659/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | `78.42% <57.50%> (-0.27%)` | :arrow_down: | | [wasm](https://app.codecov.io/gh/pion/ice/pull/659/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion) | `23.71% <0.00%> (-0.13%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pion#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.