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

Make sure Send/Receive in StatsPusher can be canceled #4139

Merged
merged 3 commits into from
Mar 30, 2021

Conversation

j16r
Copy link
Contributor

@j16r j16r commented Mar 29, 2021

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

@smartcontractkit smartcontractkit deleted a comment from github-actions bot Mar 30, 2021
@j16r j16r force-pushed the bugfix/stats_pusher_speedup_correct_ctx_use branch from 950700d to 65ddcab Compare March 30, 2021 01:13
@smartcontractkit smartcontractkit deleted a comment from github-actions bot Mar 30, 2021
@j16r j16r marked this pull request as ready for review March 30, 2021 01:15
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
@j16r j16r force-pushed the bugfix/stats_pusher_speedup_correct_ctx_use branch from 65ddcab to 31c107f Compare March 30, 2021 01:51
panic("send on unstarted explorer client")
}
func (ec *explorerClient) Send(ctx context.Context, data []byte, messageTypes ...int) {
func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why the function here?

Copy link
Contributor Author

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():
Copy link
Contributor

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) ?

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

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

@smartcontractkit smartcontractkit deleted a comment from github-actions bot Mar 30, 2021
@j16r j16r requested a review from connorwstein March 30, 2021 15:18
@j16r j16r merged commit a9220f4 into develop Mar 30, 2021
@j16r j16r deleted the bugfix/stats_pusher_speedup_correct_ctx_use branch March 30, 2021 15:51
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.

None yet

2 participants