From c8e75d2e840ced24baa9217572d10ff5bb23bb0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dziepak?= Date: Wed, 15 Jun 2016 12:44:05 +0100 Subject: [PATCH] schema: cache is_atomic() in column_definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit is_atomic() is called for each cell in mutation applies, compaction and query. Since the value doesn't change it can be easily cached which would save one indirection and virtual call. Results of perf_simple_query -c1 (median, duration 60): before after read 54611.49 55396.01 +1.44% write 65378.92 68554.25 +4.86% Signed-off-by: Paweł Dziepak Message-Id: <1465991045-11140-1-git-send-email-pdziepak@scylladb.com> --- schema.cc | 2 +- schema.hh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/schema.cc b/schema.cc index 96e7b646dc..c2e0584619 100644 --- a/schema.cc +++ b/schema.cc @@ -325,7 +325,7 @@ index_info::index_info(::index_type idx_type, {} column_definition::column_definition(bytes name, data_type type, column_kind kind, column_id component_index, index_info idx, api::timestamp_type dropped_at) - : _name(std::move(name)), _dropped_at(dropped_at), type(std::move(type)), id(component_index), kind(kind), idx_info(std::move(idx)) + : _name(std::move(name)), _dropped_at(dropped_at), _is_atomic(type->is_atomic()), type(std::move(type)), id(component_index), kind(kind), idx_info(std::move(idx)) {} std::ostream& operator<<(std::ostream& os, const column_definition& cd) { diff --git a/schema.hh b/schema.hh index 3b6c347115..d6b149df0a 100644 --- a/schema.hh +++ b/schema.hh @@ -196,6 +196,7 @@ public: private: bytes _name; api::timestamp_type _dropped_at; + bool _is_atomic; struct thrift_bits { thrift_bits() @@ -228,7 +229,7 @@ public: bool is_partition_key() const { return kind == column_kind::partition_key; } bool is_clustering_key() const { return kind == column_kind::clustering_key; } bool is_primary_key() const { return kind == column_kind::partition_key || kind == column_kind::clustering_key; } - bool is_atomic() const { return type->is_atomic(); } + bool is_atomic() const { return _is_atomic; } bool is_compact_value() const { return kind == column_kind::compact_column; } const sstring& name_as_text() const; const bytes& name() const;