-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
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. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preallocate.
Thanks! |
Addresses #15 by replacing
map[string]expiringAddr
with[]expiringAddr
, and changes the name of the typeaddrSet
toaddrSlice
, 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%.