Loading include/paritypp/server.h +4 −3 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ private: // Deleted blocks are tombstoned; vacuum rewrites the file to reclaim space. class file_block_store : public block_store { public: explicit file_block_store(const std::string& base_dir); explicit file_block_store(const std::string& base_dir, size_t write_buf_threshold = DEFAULT_WRITE_BUF_THRESHOLD); ~file_block_store() override; bool store(uint64_t group_id, uint32_t block_index, Loading @@ -96,8 +96,8 @@ private: static constexpr uint8_t RECORD_DELETED = 0xFF; // Record header: [1B flags][8B group_id][4B block_index][4B data_len] static constexpr size_t RECORD_HEADER_SIZE = 17; // Write buffer threshold: flush when buffer exceeds this size static constexpr size_t WRITE_BUF_THRESHOLD = 256 * 1024; // 256 KB // Write buffer threshold: flush when buffer exceeds this size (0 = immediate flush) static constexpr size_t DEFAULT_WRITE_BUF_THRESHOLD = 256 * 1024; // 256 KB struct block_entry { off_t offset; // file offset of the record header Loading @@ -118,6 +118,7 @@ private: // Write coalescing buffer std::vector<uint8_t> write_buf_; off_t write_buf_base_ = 0; // file offset where write_buf_ starts size_t write_buf_threshold_ = DEFAULT_WRITE_BUF_THRESHOLD; bool scan_and_build_index(); void maybe_auto_vacuum(); Loading src/server.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -133,8 +133,8 @@ std::vector<uint64_t> memory_block_store::list_groups() { // --- file_block_store (append-only binary file) --- file_block_store::file_block_store(const std::string& base_dir) : data_path_(base_dir + "/blocks.bin") { file_block_store::file_block_store(const std::string& base_dir, size_t write_buf_threshold) : data_path_(base_dir + "/blocks.bin"), write_buf_threshold_(write_buf_threshold) { std::filesystem::create_directories(base_dir); fd_ = pp_open(data_path_.c_str(), O_RDWR | O_CREAT, 0644); if (fd_ >= 0) Loading Loading @@ -259,8 +259,8 @@ bool file_block_store::store(uint64_t group_id, uint32_t block_index, ++total_blocks_; file_size_ = pos + RECORD_HEADER_SIZE + dlen; // Flush if buffer exceeds threshold if (write_buf_.size() >= WRITE_BUF_THRESHOLD) // Flush if buffer exceeds threshold (0 = flush every write) if (write_buf_.size() >= write_buf_threshold_) flush_impl(); maybe_auto_vacuum(); Loading Loading
include/paritypp/server.h +4 −3 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ private: // Deleted blocks are tombstoned; vacuum rewrites the file to reclaim space. class file_block_store : public block_store { public: explicit file_block_store(const std::string& base_dir); explicit file_block_store(const std::string& base_dir, size_t write_buf_threshold = DEFAULT_WRITE_BUF_THRESHOLD); ~file_block_store() override; bool store(uint64_t group_id, uint32_t block_index, Loading @@ -96,8 +96,8 @@ private: static constexpr uint8_t RECORD_DELETED = 0xFF; // Record header: [1B flags][8B group_id][4B block_index][4B data_len] static constexpr size_t RECORD_HEADER_SIZE = 17; // Write buffer threshold: flush when buffer exceeds this size static constexpr size_t WRITE_BUF_THRESHOLD = 256 * 1024; // 256 KB // Write buffer threshold: flush when buffer exceeds this size (0 = immediate flush) static constexpr size_t DEFAULT_WRITE_BUF_THRESHOLD = 256 * 1024; // 256 KB struct block_entry { off_t offset; // file offset of the record header Loading @@ -118,6 +118,7 @@ private: // Write coalescing buffer std::vector<uint8_t> write_buf_; off_t write_buf_base_ = 0; // file offset where write_buf_ starts size_t write_buf_threshold_ = DEFAULT_WRITE_BUF_THRESHOLD; bool scan_and_build_index(); void maybe_auto_vacuum(); Loading
src/server.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -133,8 +133,8 @@ std::vector<uint64_t> memory_block_store::list_groups() { // --- file_block_store (append-only binary file) --- file_block_store::file_block_store(const std::string& base_dir) : data_path_(base_dir + "/blocks.bin") { file_block_store::file_block_store(const std::string& base_dir, size_t write_buf_threshold) : data_path_(base_dir + "/blocks.bin"), write_buf_threshold_(write_buf_threshold) { std::filesystem::create_directories(base_dir); fd_ = pp_open(data_path_.c_str(), O_RDWR | O_CREAT, 0644); if (fd_ >= 0) Loading Loading @@ -259,8 +259,8 @@ bool file_block_store::store(uint64_t group_id, uint32_t block_index, ++total_blocks_; file_size_ = pos + RECORD_HEADER_SIZE + dlen; // Flush if buffer exceeds threshold if (write_buf_.size() >= WRITE_BUF_THRESHOLD) // Flush if buffer exceeds threshold (0 = flush every write) if (write_buf_.size() >= write_buf_threshold_) flush_impl(); maybe_auto_vacuum(); Loading