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
Move MVCCComputeStats implementation to C++. #3155
Conversation
60a5101
to
aa7ba2c
Compare
This is now ready for a look. I wish there was a good way to diff the Go and C++ implementations. |
aa7ba2c
to
83c3739
Compare
Review status: all files reviewed at latest revision, 10 unresolved discussions. storage/engine/rocksdb/db.cc, line 1240 [r1] (raw file): storage/engine/rocksdb/db.cc, line 1260 [r1] (raw file): storage/engine/rocksdb/db.cc, line 1269 [r1] (raw file): storage/engine/rocksdb/encoding.cc, line 93 [r1] (raw file): storage/engine/rocksdb/encoding.cc, line 97 [r1] (raw file): storage/engine/rocksdb/encoding.h, line 34 [r1] (raw file): storage/engine/rocksdb_test.go, line 556 [r1] (raw file): storage/replica_data_iter.go, line 70 [r1] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 10 unresolved discussions. storage/engine/engine.go, line 76 [r1] (raw file): storage/engine/mvcc_test.go, line 2548 [r1] (raw file): Comments from the review on Reviewable.io |
Reviewed 4 of 4 files at r2. storage/engine/rocksdb/db.cc, line 1273 [r2] (raw file): Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, 1 unresolved discussion. storage/engine/rocksdb/db.cc, line 1273 [r2] (raw file): Comments from the review on Reviewable.io |
@@ -115,6 +120,15 @@ DBStatus ToDBStatus(const rocksdb::Status& status) { | |||
return ToDBString(status.ToString()); | |||
} | |||
|
|||
DBStatus FmtStatus(const char *fmt, ...) { |
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.
Is this function covered in our tests anywhere? I didn't see any cases where we test for a failure of MVCCComputeStats, but I didn't do an exhaustive search. Would be good to have tests to make sure we get the memory management right here.
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.
FmtStatus
is not explicit tested, but we do have tests that exercise the code path that memory allocated by ToDBString
is freed by statusToError
. Do you have any thoughts on how to test that the memory was actually freed?
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.
I'm more concerned about returning a pointer to freed memory than a leak (I don't see any practical way to test for the absence of a leak). I'd just like to see a test where MVCCStats returns an error to make sure we execute FmtStatus at least once.
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.
Added TestMVCCComputeStatsError
which writes an mvcc metadata key with garbage for the value.
LGTM |
Replaced the Go MVCCComputeStats implementation with a C++ implementation. Had to rejigger the usage of ComputeStats during splits and merges to properly loop over all of the key ranges for a replica because the C++ implementation is unable to use the ReplicaDataIterator directly. Small price to pay for a big speed-up. name old time/op new time/op delta MVCCComputeStats1Version8Bytes-8 1.04s ± 2% 0.34s ± 1% -67.04% (p=0.000 n=10+10) MVCCComputeStats1Version32Bytes-8 737ms ± 4% 242ms ± 2% -67.23% (p=0.000 n=10+10) MVCCComputeStats1Version256Bytes-8 211ms ± 3% 86ms ± 4% -59.38% (p=0.000 n=10+10) name old speed new speed delta MVCCComputeStats1Version8Bytes-8 64.5MB/s ± 2% 195.7MB/s ± 1% +203.39% (p=0.000 n=10+10) MVCCComputeStats1Version32Bytes-8 91.0MB/s ± 4% 277.8MB/s ± 2% +205.12% (p=0.000 n=10+10) MVCCComputeStats1Version256Bytes-8 319MB/s ± 3% 785MB/s ± 5% +146.25% (p=0.000 n=10+10)
a6e57f7
to
984b878
Compare
Move MVCCComputeStats implementation to C++.
This change is a work in progress. I still need to adjust or remove the
usage of ReplicaDataIterator for stats computation in
Replica.splitTrigger.