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

fix: preserve Unlimited StreamsInbound in connmgr reconciliation #9723

Merged
merged 3 commits into from
Mar 16, 2023

Conversation

Jorropo
Copy link
Contributor

@Jorropo Jorropo commented Mar 15, 2023

Fixes #9695

@Jorropo Jorropo mentioned this pull request Mar 15, 2023
@BigLep
Copy link
Contributor

BigLep commented Mar 15, 2023

@Jorropo : do we have any tests around this?

@@ -129,7 +129,9 @@ func createDefaultLimitConfig(cfg config.SwarmConfig) (limitConfig rcmgr.Concret
}

// Scale System.StreamsInbound as well, but use the existing ratio of StreamsInbound to ConnsInbound
partialLimits.System.StreamsInbound = rcmgr.LimitVal(maxInboundConns * int64(partialLimits.System.StreamsInbound) / int64(partialLimits.System.ConnsInbound))
if partialLimits.System.StreamsInbound != rcmgr.Unlimited {
Copy link
Contributor

@guseggert guseggert Mar 15, 2023

Choose a reason for hiding this comment

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

Would it make sense to change this check to if partialLimits.System.StreamsInbound >= 0 to protect against all enums (including any future ones that are added)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That will silently ignore new enums.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's the point, we don't ever want to include enums in this calculation right?

Copy link
Contributor Author

@Jorropo Jorropo Mar 15, 2023

Choose a reason for hiding this comment

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

I don't know, maybe there is a new enum in the future that will require some new logic.

What I would want is some Rust like enum matching, where if a new enum is added the build would fail here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The same issue would occur in any language if you overload an int w/ multiple semantics depending on where a value lies in an interval.

@Jorropo
Copy link
Contributor Author

Jorropo commented Mar 15, 2023

do we have any tests around this?

This depends on the register width and is pretty deep from the config.

@BigLep
Copy link
Contributor

BigLep commented Mar 15, 2023

@Jorropo : my thinking was more that if we set partialLimits.System.StreamsInbound = rcmgr.Unlimited (or any of the other special values) we confirm that it stays the special value (e.g., rcmgr.Unlimited).

@Jorropo
Copy link
Contributor Author

Jorropo commented Mar 15, 2023

@BigLep I see, I made that, I thought you meant to test the underflow.

@guseggert see the latest commit, I think it make the code worst.
(I really wish go have compile time safe enums like Rust)

Copy link
Contributor

@BigLep BigLep left a comment

Choose a reason for hiding this comment

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

core/node/libp2p/rcmgr.go Outdated Show resolved Hide resolved
@Jorropo
Copy link
Contributor Author

Jorropo commented Mar 16, 2023

Unrelated known flaky failures.

@Jorropo Jorropo merged commit a3b4177 into ipfs:master Mar 16, 2023
@Jorropo Jorropo deleted the fix/9695 branch March 16, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Unable to initialize libp2p due to conflicting limit configuration
3 participants