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

Add errbuff to all util.startstoponce services #8642

Merged
merged 3 commits into from
Mar 7, 2023

Conversation

essamhassan
Copy link
Contributor

@essamhassan essamhassan commented Mar 7, 2023

This PR adds errbuffer to all util.startstoponce making it available to all services to use.

func benchmarkErrorBuffer(cap int, b *testing.B) {
	errbuff := utils.ErrorBuffer{}
	errbuff.SetCap(cap)
	for n := 1; n <= b.N; n++ {
		errbuff.Append(errors.New(fmt.Sprintf("err#%d", n)))
	}
    _ = errbuff.Flush().Error()
}

func BenchmarkErrorBufferDefault(b *testing.B) { benchmarkErrorBuffer(utils.DefaultErrorBufferCap, b) }
func BenchmarkErrorBuffer10(b *testing.B)      { benchmarkErrorBuffer(10, b) }
func BenchmarkErrorBuffer100(b *testing.B)     { benchmarkErrorBuffer(100, b) }
func BenchmarkErrorBuffer500(b *testing.B)     { benchmarkErrorBuffer(500, b) }


~ /usr/bin/go test -benchmem -run=^ -bench ^BenchmarkErrorBuffer github.com/smartcontractkit/chainlink/core/utils                       ✔   13s  19:10:03 
cltest random seed: 1678212606777074429
goos: linux
goarch: amd64
pkg: github.com/smartcontractkit/chainlink/core/utils
cpu: REDACTED
BenchmarkErrorBufferDefault-8            1566470               742.7 ns/op           356 B/op          5 allocs/op
BenchmarkErrorBuffer10-8                 1564142               850.4 ns/op           359 B/op          5 allocs/op
BenchmarkErrorBuffer100-8                1000000              1065 ns/op             359 B/op          5 allocs/op
BenchmarkErrorBuffer500-8                1000000              1049 ns/op             366 B/op          5 allocs/op
PASS
ok      github.com/smartcontractkit/chainlink/core/utils        9.466s
~ /usr/bin/go test -benchmem -run=^ -bench ^BenchmarkErrorBuffer github.com/smartcontractkit/chainlink/core/utils                       ✔   11s  19:10:16 
cltest random seed: 1678212620876404710
goos: linux
goarch: amd64
pkg: github.com/smartcontractkit/chainlink/core/utils
cpu: REDACTED
BenchmarkErrorBufferDefault-8            1624514               736.4 ns/op           356 B/op          5 allocs/op
BenchmarkErrorBuffer10-8                 1581696               947.5 ns/op           359 B/op          5 allocs/op
BenchmarkErrorBuffer100-8                1000000              1027 ns/op             359 B/op          5 allocs/op
BenchmarkErrorBuffer500-8                1000000              1039 ns/op             366 B/op          5 allocs/op
PASS
ok      github.com/smartcontractkit/chainlink/core/utils        9.579s
  • Next steps is to to utilize this in services for health reporting, using this as one of the signals for system health.
    ErrBuff should emit errors only classified as crits
  • Guidance is, any service that does expose Start()/Stop() interface should move to use startstoponce util

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

@essamhassan essamhassan marked this pull request as ready for review March 7, 2023 19:14
core/utils/utils.go Outdated Show resolved Hide resolved
@essamhassan essamhassan force-pushed the util/errbuff-add-services branch from 388e81d to a73b640 Compare March 7, 2023 19:33
@essamhassan essamhassan requested a review from krehermann March 7, 2023 19:40
@cl-sonarqube-production
Copy link

@essamhassan essamhassan merged commit 3170741 into develop Mar 7, 2023
@essamhassan essamhassan deleted the util/errbuff-add-services branch March 7, 2023 20:41
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.

3 participants