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

reduce allocations in net.ResolveUnspecifiedAddress #200

Closed
wants to merge 1 commit into from

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Jun 3, 2023

On the benchmark it reduces allocations from 10 allocs/op to 5 allocs/op. The benefits are greater if you have multiple interface addresses.

return []ma.Multiaddr{resolve}, nil
}

out := make([]ma.Multiaddr, 0, len(ifaceAddrs))
for _, ia := range ifaceAddrs {
// must match the first protocol to be resolve.
if ia.Protocols()[0].Code != resolve.Protocols()[0].Code {
match := false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be solved by #198.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. It's still inefficient and it's very difficult to optimise this beyond the method in the PR without doing #198.

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.

None yet

2 participants