-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
IpAddr::from_str
is unnecessarily slow for IPv6 addresses
#94825
Comments
This is true because octal addresses were banned in #83652. |
@rustbot claim |
I do agree that it could benefit the
is not true. If I didn't get it wrong, the current parser will realize the input is an IPv6 after parsing at most four bytes. And if we're going to use the input size as a factor to guess, something like |
That seems correct rust/library/std/src/net/parser.rs Lines 145 to 148 in 21b0325
|
There are probably still further performance improvements that could be made, but unless someone has a real-world use case for parsing that many IPv6 addresses, this seems unnecessary. |
My employer maintains an ETL process that mostly chomps through netflow data, spending a nontrivial amount of cycles parsing IP addresses depending on configuration. I don't particularly see any reason to close this; if we can have super-fast IP address parsing, we should. |
from_str
is implemented like so:rust/library/std/src/net/parser.rs
Lines 226 to 229 in 5f4e067
This unnecessarily penalizes ipv6 addresses, because the parser will always do a full linear scan of the input before it even starts to parse the address. Instead, it could use the knowledge that IPv4 addresses are at most 15 bytes long to skip directly to
read_ipv6_addr
for longer strings.@rustbot label: +I-slow +T-libs +C-enhancement
The text was updated successfully, but these errors were encountered: