From 490fcac07832205cb0bdb7ade24118d6567544fa Mon Sep 17 00:00:00 2001 From: leipeng Date: Wed, 29 Jun 2022 13:02:48 -0700 Subject: [PATCH] WriteBatch reorder fields to reduce padding (#10266) Summary: this reorder reduces sizeof(WriteBatch) by 16 bytes Pull Request resolved: https://github.com/facebook/rocksdb/pull/10266 Reviewed By: akankshamahajan15 Differential Revision: D37505201 Pulled By: ajkr fbshipit-source-id: 6cb6c3735073fcb63921f822d5e15670fecb1c26 --- include/rocksdb/write_batch.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/rocksdb/write_batch.h b/include/rocksdb/write_batch.h index e722bfe82..cbec33a65 100644 --- a/include/rocksdb/write_batch.h +++ b/include/rocksdb/write_batch.h @@ -447,25 +447,12 @@ class WriteBatch : public WriteBatchBase { // the WAL. SavePoint wal_term_point_; - // For HasXYZ. Mutable to allow lazy computation of results - mutable std::atomic content_flags_; - - // Performs deferred computation of content_flags if necessary - uint32_t ComputeContentFlags() const; - - // Maximum size of rep_. - size_t max_bytes_; - // Is the content of the batch the application's latest state that meant only // to be used for recovery? Refer to // TransactionOptions::use_only_the_last_commit_time_batch_for_recovery for // more details. bool is_latest_persistent_state_ = false; - std::unique_ptr prot_info_; - - size_t default_cf_ts_sz_ = 0; - // False if all keys are from column families that disable user-defined // timestamp OR UpdateTimestamps() has been called at least once. // This flag will be set to true if any of the above Put(), Delete(), @@ -479,6 +466,19 @@ class WriteBatch : public WriteBatchBase { // that enables user-defined timestamp. bool has_key_with_ts_ = false; + // For HasXYZ. Mutable to allow lazy computation of results + mutable std::atomic content_flags_; + + // Performs deferred computation of content_flags if necessary + uint32_t ComputeContentFlags() const; + + // Maximum size of rep_. + size_t max_bytes_; + + std::unique_ptr prot_info_; + + size_t default_cf_ts_sz_ = 0; + protected: std::string rep_; // See comment in write_batch.cc for the format of rep_ };