Skip to content

Conversation

@rafiss
Copy link
Collaborator

@rafiss rafiss commented Sep 26, 2025

This is to help debug an expensive error handling call path that was seen in a profile.

goos: darwin
goarch: arm64
cpu: Apple M1 Pro
=== RUN   BenchmarkErrorsIs
BenchmarkErrorsIs
=== RUN   BenchmarkErrorsIs/SimpleError
BenchmarkErrorsIs/SimpleError
BenchmarkErrorsIs/SimpleError         	 1618170	       716.0 ns/op	     448 B/op	      14 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/WrappedError
BenchmarkErrorsIs/WrappedError
BenchmarkErrorsIs/WrappedError        	  300048	      4009 ns/op	    3344 B/op	      67 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/WrappedWithStack
BenchmarkErrorsIs/WrappedWithStack
BenchmarkErrorsIs/WrappedWithStack    	  941736	      1179 ns/op	     896 B/op	      23 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/NetworkError
BenchmarkErrorsIs/NetworkError
BenchmarkErrorsIs/NetworkError        	  414190	      2790 ns/op	    1768 B/op	      52 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/DeeplyWrappedNetworkError
BenchmarkErrorsIs/DeeplyWrappedNetworkError
BenchmarkErrorsIs/DeeplyWrappedNetworkError         	   44353	     27774 ns/op	   23419 B/op	     381 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/MultipleWrappedErrors
BenchmarkErrorsIs/MultipleWrappedErrors
BenchmarkErrorsIs/MultipleWrappedErrors             	   65017	     18352 ns/op	   20259 B/op	     275 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/NetworkErrorWithLongAddress
BenchmarkErrorsIs/NetworkErrorWithLongAddress
BenchmarkErrorsIs/NetworkErrorWithLongAddress       	  111456	     10746 ns/op	    8145 B/op	     150 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/WithMessage
BenchmarkErrorsIs/WithMessage
BenchmarkErrorsIs/WithMessage                       	  520652	      2595 ns/op	    1880 B/op	      40 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/MultipleWithMessage
BenchmarkErrorsIs/MultipleWithMessage
BenchmarkErrorsIs/MultipleWithMessage               	  107244	      9438 ns/op	    6929 B/op	     122 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/WithMessageAndStack
BenchmarkErrorsIs/WithMessageAndStack
BenchmarkErrorsIs/WithMessageAndStack               	  215155	      5640 ns/op	    5296 B/op	      87 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/NetworkErrorWithMessage
BenchmarkErrorsIs/NetworkErrorWithMessage
BenchmarkErrorsIs/NetworkErrorWithMessage           	  184285	      6572 ns/op	    4648 B/op	      99 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/NetworkErrorWithEverything
BenchmarkErrorsIs/NetworkErrorWithEverything
BenchmarkErrorsIs/NetworkErrorWithEverything        	   25274	     46921 ns/op	   35885 B/op	     594 allocs/op
=== NAME
=== RUN   BenchmarkErrorsIs/DeeplyNested100Levels
BenchmarkErrorsIs/DeeplyNested100Levels
BenchmarkErrorsIs/DeeplyNested100Levels             	     256	   4702923 ns/op	 5931739 B/op	   62712 allocs/op
=== NAME

informs: #153772
Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 26, 2025

Here's a cpu profile from running ./dev bench pkg/util/errorutil -f=BenchmarkErrorsIs/NetworkErrorWithEverything --test-args '-test.cpuprofile=cpu.pb.gz -test.cpu=4'. cpu.pb.gz

CleanShot 2025-09-26 at 02 11 03@2x

It shows some similarities to the one from the roachtest, but none of the net.(*OpError) formatting shows up: #153772 (comment)

This is to help debug an expensive error handling call path that was
seen in a profile.

Release note: None
@rafiss
Copy link
Collaborator Author

rafiss commented Oct 7, 2025

The benchmark is being moved to the errors repo: cockroachdb/errors#153

@rafiss rafiss closed this Oct 7, 2025
@rafiss rafiss deleted the benchmark-errors-is branch October 7, 2025 16:25
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.

2 participants