Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

feat: cache interface addresses for 1 minute #129

Merged
merged 3 commits into from
Jun 4, 2019

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Jun 3, 2019

This can be quite an overhead in cases of high connection rates.
The main overhead is thread blocking syscall causing a lot of context
switching.

This can be quite an overhead in cases of high connection rates.
The main overhead is thread blocking syscall causing a lot of context
switching.

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@Kubuxu Kubuxu requested review from Stebalien and raulk June 3, 2019 21:16
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

so what is the expensive component here?

@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 4, 2019

Syscall to fetch all physical interface address called on every request for a swarm address list.

@vyzo
Copy link
Contributor

vyzo commented Jun 4, 2019

why not cache the addresses completely?

@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 4, 2019

We can, the question is if we want to do it.
Both listeners and interface addresses are quite stable.

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 4, 2019

Updated it to cache whole InterfaceListenAddresses.
If it comes up on profiles ever again we can swap it out with atomic values or channel generator.

(RWlocks have a nasty property of contending on one cache line, in cpp they sometimes use distributed RWLocks where reader counts are distributed across many cache lines).

@Kubuxu Kubuxu requested a review from vyzo June 4, 2019 19:49
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@Kubuxu Kubuxu force-pushed the feat/cache-interface-addrs branch from bf73c80 to 1b20b7b Compare June 4, 2019 21:12
@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 4, 2019

Fixed.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

❤️

@Stebalien Stebalien merged commit 35dc073 into master Jun 4, 2019
@Stebalien Stebalien deleted the feat/cache-interface-addrs branch June 4, 2019 23:18
@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 5, 2019

This reduced time for the bootstrap of a dht test network (using https://github.com/Kubuxu/go-libp2p-faketransport) by half.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants