From f68724c7b9392961a02bfcbb959aa4daa5929012 Mon Sep 17 00:00:00 2001 From: Roland Kuehn Date: Sun, 10 Apr 2022 16:28:28 +0200 Subject: [PATCH 1/3] Fixed typo and alignment issues on aarch64 --- include/concurrency/timestamp.h | 4 ++-- include/storage/record_identifier.h | 4 ++-- src/io/client_console.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/concurrency/timestamp.h b/include/concurrency/timestamp.h index ad45b62..70383d9 100644 --- a/include/concurrency/timestamp.h +++ b/include/concurrency/timestamp.h @@ -35,7 +35,7 @@ namespace beedb::concurrency * * The time "0" in combination with the set committed flag indicates "infinity". */ -class timestamp +class alignas(64) timestamp { public: using timestamp_t = std::uint64_t; @@ -113,4 +113,4 @@ class timestamp // Time and committed flag (last bit). timestamp_t _timestamp_and_committed_flag = 1u; }; -} // namespace beedb::concurrency \ No newline at end of file +} // namespace beedb::concurrency diff --git a/include/storage/record_identifier.h b/include/storage/record_identifier.h index 5b54f36..f0f8c2d 100644 --- a/include/storage/record_identifier.h +++ b/include/storage/record_identifier.h @@ -26,7 +26,7 @@ namespace beedb::storage { -class RecordIdentifier +class alignas(64) RecordIdentifier { public: static_assert(sizeof(Page::id_t) + sizeof(std::uint16_t) <= sizeof(std::uint64_t)); @@ -88,4 +88,4 @@ template <> struct hash return std::hash()(static_cast(rid)); } }; -} // namespace std \ No newline at end of file +} // namespace std diff --git a/src/io/client_console.cpp b/src/io/client_console.cpp index 17aa053..030b96a 100644 --- a/src/io/client_console.cpp +++ b/src/io/client_console.cpp @@ -112,7 +112,7 @@ bool ClientConsole::handle_response(const std::string &response) } else if (server_response->type() == ServerResponse::Type::ServerClosed) { - std::cout << "Server sopped." << std::endl; + std::cout << "Server stopped." << std::endl; return false; } @@ -142,4 +142,4 @@ void ClientConsole::plan_to_table(util::TextTable &table, nlohmann::json &layer, plan_to_table(table, child, depth + 2); } } -} \ No newline at end of file +} From f566edc6427957af40b0fc0e1880dc07e162ecb3 Mon Sep 17 00:00:00 2001 From: Roland Kuehn Date: Sun, 10 Apr 2022 16:42:50 +0200 Subject: [PATCH 2/3] Removed alignemnt from RecordIdentifiers --- include/concurrency/metadata.h | 10 +++++----- include/storage/record_identifier.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/concurrency/metadata.h b/include/concurrency/metadata.h index 41ed739..6bb88b1 100644 --- a/include/concurrency/metadata.h +++ b/include/concurrency/metadata.h @@ -56,7 +56,7 @@ class Metadata { _begin_timestamp.store(other._begin_timestamp.load()); _end_timestamp.store(other._end_timestamp.load()); - _next_in_version_chain.store(other._next_in_version_chain.load()); + _next_in_version_chain = other._next_in_version_chain; } ~Metadata() = default; @@ -83,7 +83,7 @@ class Metadata */ [[nodiscard]] storage::RecordIdentifier next_in_version_chain() const { - return _next_in_version_chain.load(); + return _next_in_version_chain; } /** @@ -136,7 +136,7 @@ class Metadata */ void next_in_version_chain(const storage::RecordIdentifier next) { - _next_in_version_chain.store(next); + _next_in_version_chain = next; } /** @@ -158,6 +158,6 @@ class Metadata std::atomic _end_timestamp; // Pointer to the next record in version chain. - std::atomic _next_in_version_chain; + storage::RecordIdentifier _next_in_version_chain; }; -} // namespace beedb::concurrency \ No newline at end of file +} // namespace beedb::concurrency diff --git a/include/storage/record_identifier.h b/include/storage/record_identifier.h index f0f8c2d..30803e0 100644 --- a/include/storage/record_identifier.h +++ b/include/storage/record_identifier.h @@ -26,7 +26,7 @@ namespace beedb::storage { -class alignas(64) RecordIdentifier +class RecordIdentifier { public: static_assert(sizeof(Page::id_t) + sizeof(std::uint16_t) <= sizeof(std::uint64_t)); From e35ec43ad806e9d9055bcd7c6498fc0c3e49c567 Mon Sep 17 00:00:00 2001 From: Roland Kuehn Date: Sun, 10 Apr 2022 18:58:36 +0200 Subject: [PATCH 3/3] Removed atomics in metadata (lead to crashes on aarch64) --- include/concurrency/metadata.h | 29 ++++++++++++++++++----------- include/concurrency/timestamp.h | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/concurrency/metadata.h b/include/concurrency/metadata.h index 6bb88b1..cf46e11 100644 --- a/include/concurrency/metadata.h +++ b/include/concurrency/metadata.h @@ -54,8 +54,8 @@ class Metadata : _original_record_identifier(other._original_record_identifier), _begin_timestamp(timestamp::make_infinity()), _end_timestamp(timestamp::make_infinity()) { - _begin_timestamp.store(other._begin_timestamp.load()); - _end_timestamp.store(other._end_timestamp.load()); + _begin_timestamp = other._begin_timestamp; + _end_timestamp = other._end_timestamp; _next_in_version_chain = other._next_in_version_chain; } @@ -66,7 +66,7 @@ class Metadata */ [[nodiscard]] timestamp begin_timestamp() const { - return _begin_timestamp.load(); + return _begin_timestamp; } /** @@ -75,7 +75,7 @@ class Metadata */ [[nodiscard]] timestamp end_timestamp() const { - return _end_timestamp.load(); + return _end_timestamp; } /** @@ -92,7 +92,7 @@ class Metadata */ void begin_timestamp(const timestamp timestamp) { - _begin_timestamp.store(timestamp); + _begin_timestamp = timestamp; } /** @@ -105,7 +105,11 @@ class Metadata */ bool try_begin_timestamp(timestamp old_timestamp, const timestamp timestamp) { - return _begin_timestamp.compare_exchange_strong(old_timestamp, timestamp); + if (_begin_timestamp == old_timestamp){ + _begin_timestamp = timestamp; + return true; + } + return false; } /** @@ -114,7 +118,7 @@ class Metadata */ void end_timestamp(const timestamp timestamp) { - _end_timestamp.store(timestamp); + _end_timestamp = timestamp; } /** @@ -127,7 +131,11 @@ class Metadata */ bool try_end_timestamp(timestamp old_timestamp, const timestamp timestamp) { - return _end_timestamp.compare_exchange_strong(old_timestamp, timestamp); + if (_end_timestamp == old_timestamp){ + _end_timestamp = timestamp; + return true; + } + return false; } /** @@ -147,15 +155,14 @@ class Metadata return _original_record_identifier; } - private: // Pointer to the record in the table space. storage::RecordIdentifier _original_record_identifier; // Timestamp the record begins living. - std::atomic _begin_timestamp; + timestamp _begin_timestamp; // Timestamp the record dies. - std::atomic _end_timestamp; + timestamp _end_timestamp; // Pointer to the next record in version chain. storage::RecordIdentifier _next_in_version_chain; diff --git a/include/concurrency/timestamp.h b/include/concurrency/timestamp.h index 70383d9..a64df24 100644 --- a/include/concurrency/timestamp.h +++ b/include/concurrency/timestamp.h @@ -35,7 +35,7 @@ namespace beedb::concurrency * * The time "0" in combination with the set committed flag indicates "infinity". */ -class alignas(64) timestamp +class timestamp { public: using timestamp_t = std::uint64_t;