diff --git a/benchmarks/bench_parser_comparison.cpp b/benchmarks/bench_parser_comparison.cpp index 33ee308..7f103a4 100644 --- a/benchmarks/bench_parser_comparison.cpp +++ b/benchmarks/bench_parser_comparison.cpp @@ -789,7 +789,7 @@ int main() { std::cout << "\nBenchmark completed. The WeaselDB parser is optimized for:\n"; std::cout << "- Arena-based memory allocation for reduced fragmentation\n"; std::cout << "- Streaming parsing for network protocols\n"; - std::cout << "- Zero-copy string handling with string views\n"; + std::cout << "- String views to minimize unnecessary copying\n"; std::cout << "- Base64 decoding integrated into parsing pipeline\n"; std::cout << "- Efficient reset and reuse for high-throughput scenarios\n"; diff --git a/design.md b/design.md index 0bf6e5c..7244af2 100644 --- a/design.md +++ b/design.md @@ -23,7 +23,7 @@ WeaselDB is a high-performance write-side database component designed for system - **High-performance JSON parsing** with streaming support and SIMD optimization - **Multi-threaded networking** using multiple epoll instances with unified I/O thread pool - **Configurable epoll instances** to eliminate kernel-level contention -- **Zero-copy design** throughout the pipeline +- **Optimized memory management** with arena allocation and efficient copying - **Factory pattern safety** ensuring correct object lifecycle management --- @@ -152,7 +152,7 @@ A high-performance, multi-stage, lock-free pipeline for inter-thread communicati - **Arena-backed string storage** with efficient memory management - **Move-only semantics** for optimal performance - **Builder pattern** for constructing commit requests -- **Zero-copy string views** pointing to arena-allocated memory +- **String views** pointing to arena-allocated memory to avoid unnecessary copying #### **Configuration & Optimization** @@ -242,7 +242,7 @@ The system implements a RESTful API. See [api.md](api.md) for comprehensive API 1. **Performance-first** - Every component optimized for high throughput 2. **Scalable concurrency** - Multiple epoll instances eliminate kernel contention 3. **Memory efficiency** - Arena allocation eliminates fragmentation -4. **Zero-copy** - Minimize data copying throughout pipeline +4. **Efficient copying** - Minimize unnecessary copies while accepting required ones 5. **Streaming-ready** - Support incremental processing 6. **Type safety** - Compile-time validation where possible 7. **Resource management** - RAII and move semantics throughout @@ -437,7 +437,7 @@ public: #### Arena-Based String Handling ```cpp -// Preferred: Zero-copy string view with arena allocation +// Preferred: String view with arena allocation to minimize copying std::string_view process_json_key(const char* data, ArenaAllocator& arena); // Avoid: Unnecessary string copies diff --git a/src/connection.hpp b/src/connection.hpp index 42b223e..3cd9285 100644 --- a/src/connection.hpp +++ b/src/connection.hpp @@ -70,7 +70,7 @@ struct Connection { * asynchronously by the server's I/O threads using efficient vectored * I/O. * - * @param s The data to send (string view for zero-copy efficiency) + * @param s The data to send (string view parameter for efficiency) * @param copy_to_arena If true (default), copies data to the connection's * arena for safe storage. If false, the caller must ensure the data remains * valid until all queued messages are sent. diff --git a/style.md b/style.md index a5cbc1a..b589903 100644 --- a/style.md +++ b/style.md @@ -99,7 +99,7 @@ auto addr = reinterpret_cast(ptr); // Pointer to integer conv - **Complexity must be justified with benchmarks** - measure performance impact before adding complexity - **Strive for 0% CPU usage when idle** - avoid polling, busy waiting, or unnecessary background activity - Use **inline functions** for performance-critical code (e.g., `allocate_raw`) -- **Zero-copy operations** with `std::string_view` over string copying +- **String views** with `std::string_view` to minimize unnecessary copying - **Arena allocation** for efficient memory management (~1ns vs ~20-270ns for malloc) ### Complexity Control @@ -249,7 +249,7 @@ private: - **Parameter passing:** - Pass by value for types ≤ 16 bytes (int, pointers, string_view, small structs) - Pass by const reference for types > 16 bytes (containers, large objects) -- **Return by value** for small types (≤ 16 bytes), **string_view** for zero-copy over strings +- **Return by value** for small types (≤ 16 bytes), **string_view** to avoid copying strings - **noexcept specification** for move operations and non-throwing functions ```cpp std::span operations() const { return operations_; } @@ -307,7 +307,7 @@ for (auto &precondition : preconditions_) { ### Ownership & Allocation - **Arena allocators** for request-scoped memory with **STL allocator adapters** (see Performance Focus section for characteristics) -- **String views** pointing to arena-allocated memory for zero-copy operations +- **String views** pointing to arena-allocated memory to avoid unnecessary copying - **STL containers with arena allocators require default construction after arena reset** - `clear()` is not sufficient ```cpp // STL containers with arena allocators - correct reset pattern diff --git a/todo.md b/todo.md index 14a46c6..ef054ef 100644 --- a/todo.md +++ b/todo.md @@ -42,7 +42,7 @@ - [ ] Support for HTTP redirects (3xx responses) with redirect limits - [ ] SSL/TLS support using OpenSSL for HTTPS connections - [ ] Request/response logging and metrics integration - - [ ] Memory-efficient design with zero-copy where possible + - [ ] Memory-efficient design minimizing unnecessary copying - [ ] Implement fake in-process S3 service using separate Server instance with S3 ConnectionHandler - [ ] Use create_local_connection to get fd for in-process communication - [ ] Implement `ListObjectsV2` API for object enumeration