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

Memory usage #22

Merged
merged 2 commits into from
Jan 17, 2018
Merged

Memory usage #22

merged 2 commits into from
Jan 17, 2018

Conversation

Arceliar
Copy link
Contributor

Addresses #15 by replacing map[string]expiringAddr with []expiringAddr, and changes the name of the type addrSet to addrSlice, since the latter term would now be a more accurate description.

When I profile it on my machine, on an idle ipfs, this reduces the memory usage of AddAddrs from ~45% of the total to ~15%.

@Stebalien
Copy link
Member

Nice! We actually fixed this a different way by not advertising and storing a bunch of ephemeral addresses permanently (oops) but I don't see any reason not to accept this change as well.

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.

Thanks!

addr_manager.go Outdated
delete(maddrs, s)
}
if len(maddrs) == 0 {
mgr.addrs[p] = cleaned
Copy link
Member

Choose a reason for hiding this comment

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

This line probably shouldn't be here.

addr_manager.go Outdated
if !found {
amap = make(addrSet)
mgr.addrs[p] = amap
amap := make(map[string]expiringAddr)
Copy link
Member

Choose a reason for hiding this comment

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

Should probably preallocate.

addr_manager.go Outdated
if !found {
amap = make(addrSet)
mgr.addrs[p] = amap
amap := make(map[string]expiringAddr)
Copy link
Member

Choose a reason for hiding this comment

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

Preallocate.

@Stebalien Stebalien merged commit 020aa74 into libp2p:master Jan 17, 2018
@Stebalien
Copy link
Member

Thanks!

@Arceliar Arceliar deleted the memusage branch January 25, 2018 19:17
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.

None yet

2 participants