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

[release-v1.7] main: Use backported addrmgr updates. #3084

Merged
merged 6 commits into from
Apr 7, 2023

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 7, 2023

This updates the 1.7 release to use the latest version of the addrmgr module which includes updates to mitigate excessive CPU usage in testnet scenarios and slightly improve address selection efficiency.

In particular, the following updated module version is used:

Note that it also cherry picks all of the commits included in updates to the addrmgr/v2 module to ensure they are also included in the release branch even though it is not strictly necessary since the go.mod has been updated to require the new addrmgr/v2.0.1 release and thus will pull in the new code. However, from past experience, not having code backported to modules available in the release branch too leads to headaches for devs building from source in their local workspace with overrides such as those in go.work.

@davecgh davecgh added this to the 1.7.6 milestone Apr 7, 2023
davecgh and others added 6 commits April 6, 2023 20:58
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.
This bumps the go directive for the addrmgr module to 1.17 which will allow
the new module graph pruning and lazy loading capabilities introduced in
Go 1.17 to be used once the updated modules are released.

This means that, as described by the documentation, the go.mod file for
the module now include a separate require block that includes all of the
indirect dependencies.
This modifies the addrmgr module to use the new formatting of doc
comments in the Go 1.19 release.
This adds a missing break statement to the range over the map of
addresses used to select a random entry from the map.  Previously
the loop would continue needlessly until the entire map was traversed.
This is a minor optimization.
This updates the (*KnownAddress).chance method in the following ways:
1. Apply a lower limit to the return value.  Using 0.01  as this minimum
   prevents tiny chance values from causing excessive iterations in
   (*AddrManager).GetAddress, currently the only caller.
2. Replace an inefficient loop with a single math.Pow.

These changes are mitigations to excessive CPU use in the GetAddress
method that manifest when the number of attempts for a KnownAddress
becomes large.  However, this method and much of addrmgr should be
rewritten in the future since there are some ad hoc and questionable
approaches to candidate address selection.
This updates the 1.7 release to use the latest version of the addrmgr
module which includes updates to mitigate excessive CPU usage in testnet
scenarios and slightly improve address selection efficiency.

In particular, the following updated module version is used:

- github.com/decred/dcrd/addrmgr/[email protected]
@davecgh davecgh force-pushed the rel17_addrmgr_backports branch from 138a6ee to 2a3304b Compare April 7, 2023 01:58
@davecgh davecgh merged commit 2a3304b into decred:release-v1.7 Apr 7, 2023
@davecgh davecgh deleted the rel17_addrmgr_backports branch April 7, 2023 02:09
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.

2 participants