diff --git a/src/arena.cpp b/src/arena.cpp index 2319061..0ecfce6 100644 --- a/src/arena.cpp +++ b/src/arena.cpp @@ -5,36 +5,6 @@ #include #include -Arena::~Arena() { - while (current_block_) { - Block *prev = current_block_->prev; - std::free(current_block_); - current_block_ = prev; - } -} - -Arena::Arena(Arena &&other) noexcept - : initial_block_size_(other.initial_block_size_), - current_block_(other.current_block_) { - other.current_block_ = nullptr; -} - -Arena &Arena::operator=(Arena &&other) noexcept { - if (this != &other) { - while (current_block_) { - Block *prev = current_block_->prev; - std::free(current_block_); - current_block_ = prev; - } - - initial_block_size_ = other.initial_block_size_; - current_block_ = other.current_block_; - - other.current_block_ = nullptr; - } - return *this; -} - void Arena::reset() { if (!current_block_) { return; diff --git a/src/arena.hpp b/src/arena.hpp index f8d4298..15a3be1 100644 --- a/src/arena.hpp +++ b/src/arena.hpp @@ -154,7 +154,13 @@ public: * Traverses the intrusive linked list backwards from current_block_, * freeing each block. This ensures no memory leaks. */ - ~Arena(); + ~Arena() { + while (current_block_) { + Block *prev = current_block_->prev; + std::free(current_block_); + current_block_ = prev; + } + } /// Copy construction is not allowed (would be expensive and error-prone) Arena(const Arena &) = delete; @@ -173,7 +179,11 @@ public: * - used_bytes(), total_bytes() return 0 * - Destructor is safe to call */ - Arena(Arena &&other) noexcept; + Arena(Arena &&other) noexcept + : initial_block_size_(other.initial_block_size_), + current_block_(other.current_block_) { + other.current_block_ = nullptr; + } /** * @brief Move assignment operator - transfers ownership of all blocks. @@ -191,7 +201,21 @@ public: * - used_bytes(), total_bytes() return 0 * - Destructor is safe to call */ - Arena &operator=(Arena &&other) noexcept; + Arena &operator=(Arena &&other) noexcept { + if (this != &other) { + while (current_block_) { + Block *prev = current_block_->prev; + std::free(current_block_); + current_block_ = prev; + } + + initial_block_size_ = other.initial_block_size_; + current_block_ = other.current_block_; + + other.current_block_ = nullptr; + } + return *this; + } /** * @brief Allocate raw memory with the specified size and alignment. diff --git a/src/commit_pipeline.hpp b/src/commit_pipeline.hpp index 25d7a52..95eb715 100644 --- a/src/commit_pipeline.hpp +++ b/src/commit_pipeline.hpp @@ -106,7 +106,7 @@ private: // Lock-free pipeline configuration static constexpr int lg_size = 16; // Ring buffer size (2^16 slots) - static constexpr auto wait_strategy = WaitStrategy::WaitIfUpstreamIdle; + static constexpr auto wait_strategy = WaitStrategy::WaitIfStageEmpty; // 4-stage pipeline: sequence -> resolve -> persist -> release StaticThreadPipeline pipeline_; diff --git a/src/http_handler.cpp b/src/http_handler.cpp index c688c95..62a971b 100644 --- a/src/http_handler.cpp +++ b/src/http_handler.cpp @@ -210,17 +210,7 @@ void HttpHandler::on_batch_complete(std::span batch) { void HttpHandler::on_data_arrived(std::string_view data, Connection &conn) { auto *state = static_cast(conn.user_data); - if (!state) { - // Create a temporary arena and add error response directly to avoid - // sequence issues - auto json_response = R"({"error":"Internal server error"})"; - auto http_response = - format_json_response(500, json_response, state->pending.arena, 0, true); - state->send_ordered_response(conn, state->get_next_sequence_id(), - http_response, std::move(state->pending.arena), - true); - return; - } + assert(state); // TODO: Enforce the configured max_request_size_bytes limit here. // Should track cumulative bytes received for the current HTTP request diff --git a/test_config.toml b/test_config.toml index d77b0db..a216a35 100644 --- a/test_config.toml +++ b/test_config.toml @@ -27,3 +27,6 @@ request_id_retention_versions = 100000000 max_buffer_size_bytes = 10485760 # 10MB # Interval for sending keepalive comments to prevent idle timeouts (seconds) keepalive_interval_seconds = 30 + +[benchmark] +ok_resolve_iterations = 0