-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
storage: performance regression in EncodeMVCCKey
and EncodeMVCCValue
#88818
Comments
I did some digging on this - I started with the We're spending more time in If I remove the Go 1.19 patch (2675c7c), I see the following delta, which shows gains in the opposite direction (i.e. performance improved):
Probably worth digging into this further, despite the cc: @erikgrinaker |
Working on a fix, which may give a nice boost over 22.1. |
Hi @erikgrinaker, please add branch-* labels to identify which branch(es) this release-blocker affects. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
Thanks for digging into this @erikgrinaker! Even though this is closed, I was curious as to why this was slower on go1.19, so I kept digging. Here's how Go is compiling TEXT test.Timestamp.IsEmpty(SB) /Users/nickt/Downloads/test/main.go
return t == Timestamp{}
0x10ef080 4885c0 TESTQ AX, AX
0x10ef083 7509 JNE 0x10ef08e
0x10ef085 85db TESTL BX, BX
0x10ef087 7505 JNE 0x10ef08e
0x10ef089 83f101 XORL $0x1, CX
0x10ef08c eb02 JMP 0x10ef090
0x10ef08e 31c9 XORL CX, CX
0x10ef090 89c8 MOVL CX, AX
0x10ef092 c3 RET
0x10ef093 cc INT $0x3
0x10ef094 cc INT $0x3
0x10ef095 cc INT $0x3
0x10ef096 cc INT $0x3
0x10ef097 cc INT $0x3
0x10ef098 cc INT $0x3
0x10ef099 cc INT $0x3
0x10ef09a cc INT $0x3
0x10ef09b cc INT $0x3
0x10ef09c cc INT $0x3
0x10ef09d cc INT $0x3
0x10ef09e cc INT $0x3
0x10ef09f cc INT $0x3
TEXT test.makeTS(SB) /Users/nickt/Downloads/test/main.go
return Timestamp{WallTime: walltime, Logical: logical}
0x10ef0a0 31c9 XORL CX, CX
0x10ef0a2 c3 RET And in go1.19: TEXT test.Timestamp.IsEmpty(SB) /Users/nickt/Downloads/test/main.go
func (t Timestamp) IsEmpty() bool {
0x10f4a60 493b6610 CMPQ 0x10(R14), SP
0x10f4a64 764f JBE 0x10f4ab5
0x10f4a66 4883ec40 SUBQ $0x40, SP
0x10f4a6a 48896c2438 MOVQ BP, 0x38(SP)
0x10f4a6f 488d6c2438 LEAQ 0x38(SP), BP
return t == Timestamp{}
0x10f4a74 4889442428 MOVQ AX, 0x28(SP)
0x10f4a79 895c2430 MOVL BX, 0x30(SP)
0x10f4a7d 884c2434 MOVB CL, 0x34(SP)
0x10f4a81 48c744241800000000 MOVQ $0x0, 0x18(SP)
0x10f4a8a c744242000000000 MOVL $0x0, 0x20(SP)
0x10f4a92 c644242400 MOVB $0x0, 0x24(SP)
0x10f4a97 488d442428 LEAQ 0x28(SP), AX
0x10f4a9c 488d5c2418 LEAQ 0x18(SP), BX
0x10f4aa1 b90d000000 MOVL $0xd, CX
0x10f4aa6 e8f5e4f0ff CALL runtime.memequal(SB)
0x10f4aab 488b6c2438 MOVQ 0x38(SP), BP
0x10f4ab0 4883c440 ADDQ $0x40, SP
0x10f4ab4 c3 RET
func (t Timestamp) IsEmpty() bool {
0x10f4ab5 4889442408 MOVQ AX, 0x8(SP)
0x10f4aba 895c2410 MOVL BX, 0x10(SP)
0x10f4abe 884c2414 MOVB CL, 0x14(SP)
0x10f4ac2 e839eff6ff CALL runtime.morestack_noctxt.abi0(SB)
0x10f4ac7 488b442408 MOVQ 0x8(SP), AX
0x10f4acc 8b5c2410 MOVL 0x10(SP), BX
0x10f4ad0 0fb64c2414 MOVZX 0x14(SP), CX
0x10f4ad5 eb89 JMP test.Timestamp.IsEmpty(SB)
0x10f4ad7 cc INT $0x3
0x10f4ad8 cc INT $0x3
0x10f4ad9 cc INT $0x3
0x10f4ada cc INT $0x3
0x10f4adb cc INT $0x3
0x10f4adc cc INT $0x3
0x10f4add cc INT $0x3
0x10f4ade cc INT $0x3
0x10f4adf cc INT $0x3
TEXT test.makeTS(SB) /Users/nickt/Downloads/test/main.go
return Timestamp{WallTime: walltime, Logical: logical}
0x10f4ae0 31c9 XORL CX, CX
0x10f4ae2 c3 RET The latter calls Curious as to why the compiler wants to take this approach in newer versions. It's significantly slower. Are we worried that this will crop up elsewhere? |
Thanks for getting to the bottom of this @nicktrav, this makes sense. Seems like the upstream fix won't make it into the 1.19 line. I'm not super-worried about this, since roachperf benchmarks aren't showing any significant regressions over 22.1. I also did a simple regex-based search for empty struct comparisons, and none of them appeared to be in particularly hot paths where this would matter. However, it might be worth doing an AST search if there are any decent tools for it. I happen to know of one site that might matter though, in cockroach/pkg/storage/mvcc_value.go Line 195 in 2675c7c
|
Same effect on
|
Reopening this to track |
EncodeMVCCKey
EncodeMVCCKey
and EncodeMVCCValue
Describe the problem
Currently, on the 22.2 release branch there is a sizable performance regression in
EncodeMVCCKey
, relative to 22.1:The above was generated by comparing benchmark results between 22.1 (9eb4da2) to 22.2 (054f32b), via the following:
Jira issue: CRDB-19971
Epic CRDB-2624
The text was updated successfully, but these errors were encountered: