-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make sure Send/Receive in StatsPusher can be canceled #4139
Conversation
950700d
to
65ddcab
Compare
Before: ok github.com/smartcontractkit/chainlink/core/services/synchronization 79.264s After: (ctx first step) ok github.com/smartcontractkit/chainlink/core/services/synchronization 52.237s
Before: ok github.com/smartcontractkit/chainlink/core/services/synchronization 45.389s After: (Start() optimization) ok github.com/smartcontractkit/chainlink/core/services/synchronization 0.386s
65ddcab
to
31c107f
Compare
panic("send on unstarted explorer client") | ||
} | ||
func (ec *explorerClient) Send(ctx context.Context, data []byte, messageTypes ...int) { | ||
func() { |
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.
why the function here?
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.
To limit the scope of the boot lock
@@ -166,6 +163,8 @@ func (ec *explorerClient) Send(data []byte, messageTypes ...int) { | |||
select { | |||
case send <- data: | |||
atomic.StoreUint32(&ec.dropMessageCount, 0) | |||
case <-ctx.Done(): |
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.
I think this one isn't really needed because of the default
but just there for symmetry with Receive
(where it does seem actually needed) ?
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.
To avoid logging the buffer full message if the Send gets shut down.
wg := &sync.WaitGroup{} | ||
wg.Add(1) | ||
go ec.connectAndWritePump(ctx, wg) |
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.
I'm not following why we even need this goroutine here? If we're going to wg.Wait() right after starting it we can just make a blocking call to connectAndWritePump or even inline that code here
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.
Yup, I get rid of this here: #4141
The StatsPusher tests are very slow, this should speed them up a bit...
Before:
ok github.com/smartcontractkit/chainlink/core/services/synchronization 79.264s
After: (ctx first step)
ok github.com/smartcontractkit/chainlink/core/services/synchronization 52.237s
Before: -run Auth
ok github.com/smartcontractkit/chainlink/core/services/synchronization 45.389s
After: (Start() optimization) -run Auth
ok github.com/smartcontractkit/chainlink/core/services/synchronization 0.386s
final:
ok github.com/smartcontractkit/chainlink/core/services/synchronization 8.971s