-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
move the go-libp2p-connmgr here #1297
Merged
Merged
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
973781e
first commit
whyrusleeping 29a8c4e
add base repo files
whyrusleeping 4b86097
Add a test
whyrusleeping e4074aa
make it inspectable and disableable
whyrusleeping 93b0a9a
don't try to close a connection while holding a lock that blocks the …
whyrusleeping 1fd3dd4
extract interface
whyrusleeping ef60476
faster, cleaner connection closing
Stebalien 25616aa
remove the DefaultGracePeriod
Stebalien d808b69
Merge pull request #7 from libp2p/fix/cleanup-connmgr
Stebalien d662cce
add a way to expose info from the conn manager
whyrusleeping 88f2b70
demote error message to info
whyrusleeping f724bff
add docs to BasicConnMgr
raulk 02481e7
gofmt.
raulk c5de9b3
Merge pull request #21 from raulk/feat/docs
Stebalien 2ae3cfd
lift test coverage
wetterj 2e2a793
add comments for tag functions to silence golint
wetterj 6f4d058
Merge pull request #22 from wetterj/master
Stebalien 55a490b
fix silence period between trims not being honored.
raulk 97f80a6
switch to channel-based semaphore to ensure one trim in progress.
raulk e597ebd
Merge pull request #26 from raulk/fix/concurrency-and-silence-period
raulk 3f15992
add peer protection capability to conn mgr.
raulk c19c1f3
scope protections by tag to avoid cross-interference.
raulk d8faea6
Merge pull request #36 from libp2p/feat/protect
raulk 08cdc19
implement UpsertTag
vyzo 4da4a82
Merge pull request #38 from libp2p/feat/upsert-tag
vyzo dbd00cd
implement segmented lock to eliminate big lock contention
vyzo 30f9525
fix tests
vyzo 96ea7fc
add benchmark for lock contention (possibly inaccurate).
raulk c7917a3
fix bench_test to use TagPeer in parallel goroutines
vyzo 68c9087
fix some issues in connection trimming
vyzo a696dc0
revert racey last trim check
vyzo 0ad5be2
fix peer comparison to low water mark
vyzo c9ef3d9
index string directly to avoid intermediate byte slice
vyzo 72e8628
implement background trimming
vyzo 75cc618
fix tests
vyzo 234c13d
fix issue #44
vyzo 2dcf306
Merge pull request #43 from libp2p/feat/background-trimming
vyzo 90574a9
Buffer early tags in temporary entries (#39)
raulk 65aca08
migrate to consolidated types (#45)
raulk f727593
don't count connections in the grace period against the limit
Stebalien ac5292e
pre-compute grace period
Stebalien d7ecbe5
Merge pull request #50 from libp2p/fix/46
Stebalien b200369
fix: trim connections every gracePeriod/2
Stebalien f1d6c94
feat: block on trim
Stebalien 99ddcd1
fix: simplify trim logic
Stebalien 9367628
docs: document TrimOpenConns
Stebalien bce720e
implement decaying tags. (#61)
raulk 9fba560
decaying tags: support removal and closure. (#72)
raulk f237862
implement IsProtected interface
vyzo c66854c
Merge pull request #76 from libp2p/feat/protected-query
vyzo d7f3ee5
fix staticcheck
marten-seemann a309beb
Merge pull request #78 from libp2p/fix-staticcheck
Stebalien 8c67579
Merge pull request #52 from libp2p/fix/51
Stebalien 16dce8a
fix build
marten-seemann 169748c
Merge pull request #84 from libp2p/fix-build
Stebalien 44a21dc
update go-log to v2
marten-seemann 628e658
make sure the background go routine has stopped when closing
marten-seemann 7122409
unexport the config
marten-seemann 2d47692
Merge pull request #88 from libp2p/update-go-log
marten-seemann 0ea56a8
Merge pull request #90 from libp2p/unexport-config
marten-seemann 4aeb0b9
fix race condition in getConnsToClose
marten-seemann 4533d5e
add a test case
marten-seemann d51cbad
Merge pull request #85 from libp2p/fix-race
marten-seemann e248964
add an error return value to the constructor
marten-seemann 9712afb
Merge pull request #87 from libp2p/constructor-return-value
marten-seemann cb6c410
remove check for the last trim time when trimming
marten-seemann 36cd992
Merge pull request #92 from libp2p/remove-last-trim-check
marten-seemann 414856b
introduce WithGracePeriod and WithSilencePeriod configuration options
marten-seemann 1dc5466
Merge pull request #93 from libp2p/period-config
marten-seemann b1842df
fix flaky tests caused by super short silence periods
marten-seemann dfe8394
Merge pull request #96 from libp2p/fix-flaky-single-tag-test
marten-seemann 03958f6
aggressively trim connections when we're running out of memory
marten-seemann a8a2eaa
rework concurrency logic for trims
marten-seemann 3412150
sort connections by direction and number of streams in a memory emerg…
marten-seemann ff0577e
always trim to the low watermark in a memory emergency
marten-seemann 1a3d6a6
Merge pull request #86 from libp2p/memory-emergency
marten-seemann ee3785b
make emergency trimming optional, disabled by default
vyzo b2736df
Merge pull request #101 from libp2p/fix/non-default-emergency-trimming
vyzo e32c458
hide watchdog behind cgo flag (#103)
marten-seemann 263a1a6
move the go-libp2p-connmgr here
marten-seemann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package connmgr | ||
|
||
import ( | ||
"math/rand" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/libp2p/go-libp2p-core/network" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func randomConns(tb testing.TB) (c [5000]network.Conn) { | ||
for i := range c { | ||
c[i] = randConn(tb, nil) | ||
} | ||
return c | ||
} | ||
|
||
func BenchmarkLockContention(b *testing.B) { | ||
conns := randomConns(b) | ||
cm, err := NewConnManager(1000, 1000, WithGracePeriod(0)) | ||
require.NoError(b, err) | ||
not := cm.Notifee() | ||
|
||
kill := make(chan struct{}) | ||
var wg sync.WaitGroup | ||
|
||
for i := 0; i < 16; i++ { | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
for { | ||
select { | ||
case <-kill: | ||
return | ||
default: | ||
cm.TagPeer(conns[rand.Intn(len(conns))].RemotePeer(), "another-tag", 1) | ||
} | ||
} | ||
}() | ||
} | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
rc := conns[rand.Intn(len(conns))] | ||
not.Connected(nil, rc) | ||
cm.TagPeer(rc.RemotePeer(), "tag", 100) | ||
cm.UntagPeer(rc.RemotePeer(), "tag") | ||
not.Disconnected(nil, rc) | ||
} | ||
close(kill) | ||
wg.Wait() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
that a problem?
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.
It's hidden behind the cgo flag (libp2p/go-libp2p-connmgr#103).