-
Notifications
You must be signed in to change notification settings - Fork 116
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
chore(dot/network): improve CPU usage again; no more mallocs #1608
Changes from 22 commits
45e059b
5197340
8d96671
42e2f44
161406e
aa538da
735c60f
bcc5e6f
db5ebf2
35200ba
78895dd
ef61ee8
60afa84
8e70013
4af4f95
fb467b1
56c1aaa
aa58de6
e1563f3
c8b5544
8d54da5
0ef575d
3f3055e
5565d90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ const ( | |
blockAnnounceID = "/block-announces/1" | ||
transactionsID = "/transactions/1" | ||
|
||
maxMessageSize = 1024 * 1024 // 1mb for now | ||
maxMessageSize = 1024 * 63 // 63kb for now | ||
) | ||
|
||
var ( | ||
|
@@ -139,10 +139,10 @@ func NewService(cfg *Config) (*Service, error) { | |
var bufPool *sizedBufferPool | ||
if cfg.noPreAllocate { | ||
bufPool = &sizedBufferPool{ | ||
c: make(chan *[maxMessageSize]byte, cfg.MaxPeers*3), | ||
c: make(chan *[maxMessageSize]byte, cfg.MinPeers*3), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: why *3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's currently 3 notifications protocols supported, so the number of open streams is likely to be peercount * 3 (I think the comment explains this) |
||
} | ||
} else { | ||
bufPool = newSizedBufferPool((cfg.MaxPeers-cfg.MinPeers)*3/2, (cfg.MaxPeers+1)*3) | ||
bufPool = newSizedBufferPool(cfg.MinPeers*3, cfg.MaxPeers*3) | ||
} | ||
|
||
network := &Service{ | ||
|
@@ -465,20 +465,15 @@ func (s *Service) IsStopped() bool { | |
|
||
// SendMessage implementation of interface to handle receiving messages | ||
func (s *Service) SendMessage(msg NotificationsMessage) { | ||
if s.host == nil { | ||
return | ||
} | ||
if s.IsStopped() { | ||
return | ||
} | ||
if msg == nil { | ||
logger.Debug("Received nil message from core service") | ||
if s.host == nil || msg == nil || s.IsStopped() { | ||
return | ||
} | ||
|
||
logger.Debug( | ||
"Broadcasting message from core service", | ||
"gossiping message", | ||
"host", s.host.id(), | ||
"type", msg.Type(), | ||
"message", msg, | ||
) | ||
|
||
// check if the message is part of a notifications protocol | ||
|
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.
nit: I prefer to put these configurable settings inside the struct, so
discovery
in this case.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.
would you put them inside the struct then assign the value inside
newDiscovery
?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.
Yea then you can set your desired timeout in the tests per
*discovery
rather than globally through the package.