From 4207872fc32a2b27ab511fd74380238ba1b55dc9 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 20 Jun 2022 19:15:59 -0700 Subject: [PATCH] Reduce a duplicate consistency check when applying a new version (#10169) Summary: One consistency check in SaveTo() is dupilcated with the one within Apply(). Remove one of then in release mode to reduce time spent in DB mutex. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10169 Test Plan: Run existing tests and see nothing breaks. Reviewed By: ltamasi Differential Revision: D37157821 fbshipit-source-id: 73b89443a20b43362ff66d10b9212022034a8234 --- db/version_builder.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/version_builder.cc b/db/version_builder.cc index ed340e602..d75ab1b00 100644 --- a/db/version_builder.cc +++ b/db/version_builder.cc @@ -1144,10 +1144,15 @@ class VersionBuilder::Rep { // Save the current state in *vstorage. Status SaveTo(VersionStorageInfo* vstorage) const { - Status s = CheckConsistency(base_vstorage_); + Status s; + +#ifndef NDEBUG + // The same check is done within Apply() so we skip it in release mode. + s = CheckConsistency(base_vstorage_); if (!s.ok()) { return s; } +#endif // NDEBUG s = CheckConsistency(vstorage); if (!s.ok()) {