-
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: clean up MVCC key encoding functions #75721
storage: clean up MVCC key encoding functions #75721
Conversation
c5a0c2f
to
9035872
Compare
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.
Reviewed 4 of 6 files at r1, 18 of 19 files at r2, 3 of 3 files at r3, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)
Nice to see this cleanup. |
9035872
to
887dddd
Compare
This splits MVCC keys and their encoding into a separate file, following the same convention as `engine_key.go`. There is additional decoding logic in `enginepb/decode.go` which has not been moved -- this was originally to avoid a RocksDB CGo dependency for these functions, but Pebble still has a (tiny) CGo dependency so we leave them for now. Release note: None
Release note: None
In particular, this separates the timestamp encoding from the overall key encoding. This is necessary for the MVCC range tombstone work, where Pebble key suffixes (timestamps) are processed in isolation. Unfortunately, this adds ~9% overhead for `EncodeMVCCKey()`. This was found to be due to additional function call overhead, and the Go compiler's unwillingness to inline these. This was considered acceptable for the encode path, while with the hotter `DecodeMVCCKey()` path the timestamp decoding logic was instead duplicated to avoid this overhead. ``` name old time/op new time/op delta EncodeMVCCKey/key=empty/ts=empty-24 15.8ns ± 0% 15.7ns ± 0% -0.46% (p=0.000 n=10+10) EncodeMVCCKey/key=empty/ts=walltime-24 17.9ns ± 0% 19.5ns ± 0% +8.88% (p=0.000 n=10+10) EncodeMVCCKey/key=empty/ts=walltime+logical-24 18.5ns ± 0% 20.1ns ± 0% +8.99% (p=0.000 n=10+10) EncodeMVCCKey/key=empty/ts=all-24 18.8ns ± 0% 20.4ns ± 0% +8.66% (p=0.000 n=10+10) EncodeMVCCKey/key=short/ts=walltime+logical-24 19.1ns ± 0% 20.7ns ± 0% +8.38% (p=0.000 n=10+9) EncodeMVCCKey/key=short/ts=all-24 19.5ns ± 0% 20.7ns ± 0% +6.18% (p=0.000 n=10+9) EncodeMVCCKey/key=short/ts=empty-24 16.3ns ± 0% 16.0ns ± 0% -1.86% (p=0.000 n=10+10) EncodeMVCCKey/key=short/ts=walltime-24 18.1ns ± 0% 20.6ns ± 0% +13.41% (p=0.000 n=8+8) EncodeMVCCKey/key=long/ts=empty-24 58.7ns ± 0% 58.8ns ± 0% +0.15% (p=0.000 n=10+10) EncodeMVCCKey/key=long/ts=walltime-24 59.8ns ± 0% 60.8ns ± 0% +1.78% (p=0.000 n=10+9) EncodeMVCCKey/key=long/ts=walltime+logical-24 60.7ns ± 0% 61.7ns ± 0% +1.54% (p=0.000 n=10+10) EncodeMVCCKey/key=long/ts=all-24 60.9ns ± 0% 61.9ns ± 0% +1.60% (p=0.000 n=10+9) DecodeMVCCKey/key=empty/ts=empty-24 12.4ns ± 0% 12.4ns ± 0% ~ (p=0.912 n=10+6) DecodeMVCCKey/key=empty/ts=walltime-24 13.3ns ± 0% 13.3ns ± 0% ~ (p=0.054 n=10+10) DecodeMVCCKey/key=empty/ts=walltime+logical-24 13.3ns ± 0% 13.3ns ± 0% -0.06% (p=0.034 n=10+10) DecodeMVCCKey/key=empty/ts=all-24 13.6ns ± 0% 13.6ns ± 0% ~ (p=0.509 n=10+10) DecodeMVCCKey/key=short/ts=walltime+logical-24 13.3ns ± 0% 13.3ns ± 0% ~ (all equal) DecodeMVCCKey/key=short/ts=all-24 13.6ns ± 0% 13.6ns ± 0% ~ (p=0.151 n=10+10) DecodeMVCCKey/key=short/ts=empty-24 12.5ns ± 0% 12.4ns ± 0% -0.21% (p=0.000 n=10+10) DecodeMVCCKey/key=short/ts=walltime-24 13.3ns ± 0% 13.3ns ± 0% ~ (p=0.577 n=8+10) DecodeMVCCKey/key=long/ts=walltime+logical-24 13.3ns ± 0% 13.3ns ± 0% ~ (all equal) DecodeMVCCKey/key=long/ts=all-24 13.6ns ± 0% 13.6ns ± 0% ~ (p=0.650 n=10+10) DecodeMVCCKey/key=long/ts=empty-24 12.4ns ± 0% 12.4ns ± 0% +0.15% (p=0.004 n=10+10) DecodeMVCCKey/key=long/ts=walltime-24 13.3ns ± 0% 13.3ns ± 0% +0.10% (p=0.012 n=10+9) ``` Release note: None
887dddd
to
a72dbea
Compare
TFTRs! bors r=jbowens,sumeerbhola |
Build succeeded: |
storage: move MVCC key/encoding logic into separate file
This splits MVCC keys and their encoding into a separate file, following
the same convention as
engine_key.go
. There is additional decodinglogic in
enginepb/decode.go
which has not been moved -- this wasoriginally to avoid a RocksDB CGo dependency for these functions, but
Pebble still has a (tiny) CGo dependency so we leave them for now.
Release note: None
storage: include MVCC in names of key encoding functions
Release note: None
storage: clean up MVCC key encoding functions
In particular, this separates the timestamp encoding from the overall
key encoding. This is necessary for the MVCC range tombstone work, where
Pebble key suffixes (timestamps) are processed in isolation.
Unfortunately, this adds ~9% overhead for
EncodeMVCCKey()
. This wasfound to be due to additional function call overhead, and the Go
compiler's unwillingness to inline these. This was considered acceptable
for the encode path, while with the hotter
DecodeMVCCKey()
path thetimestamp decoding logic was instead duplicated to avoid this overhead.
Release note: None