diff --git a/design.md b/design.md index 1dedd12..8a5da7b 100644 --- a/design.md +++ b/design.md @@ -55,16 +55,19 @@ ninja test # or ctest - `./test_http_handler` - HTTP protocol handling tests - `./test_metric` - Metrics system tests - `./test_api_url_parser` - API URL parsing tests +- `./test_reference` - Reference counting system tests - `./test_server_connection_return` - Connection lifecycle tests **Benchmarking:** - `./bench_arena` - Memory allocation performance - `./bench_commit_request` - JSON parsing performance -- `./bench_parser_comparison` - Compare vs nlohmann::json and RapidJSON -- `./bench_metric` - Metrics system performance -- `./bench_thread_pipeline` - Lock-free pipeline performance +- `./bench_cpu_work` - CPU work benchmarking utility - `./bench_format_comparison` - String formatting performance +- `./bench_metric` - Metrics system performance +- `./bench_parser_comparison` - Compare vs nlohmann::json and RapidJSON +- `./bench_reference` - Reference counting performance +- `./bench_thread_pipeline` - Lock-free pipeline performance **Debug tools:** @@ -272,7 +275,7 @@ WeaselDB uses `EPOLLONESHOT` for all connection file descriptors to enable safe 1. **Event Trigger**: Network thread gets epoll event → connection auto-disarmed via ONESHOT 1. **Safe Transfer**: Handler can take ownership (`std::move(conn_ptr)`) with no epoll interference 1. **Async Processing**: Connection processed on handler thread while epoll cannot trigger spurious events -1. **Return & Re-arm**: `Server::receiveConnectionBack()` re-arms fd with `epoll_ctl(EPOLL_CTL_MOD)` +1. **Return & Re-arm**: Internal server method re-arms fd with `epoll_ctl(EPOLL_CTL_MOD)` via `Server::release_back_to_server()` **Performance Trade-off:** @@ -475,7 +478,7 @@ public: } void on_write_progress(std::unique_ptr &conn) override { - if (conn->outgoingBytesQueued() == 0) { + if (conn->outgoing_bytes_queued() == 0) { // Don't use an unbounded amount of memory conn->reset(); // Write "y\n" repeatedly diff --git a/src/connection.hpp b/src/connection.hpp index 0d0d740..1aca340 100644 --- a/src/connection.hpp +++ b/src/connection.hpp @@ -196,17 +196,17 @@ struct Connection { * Use cases: * ```cpp * // Check if all data has been sent - * if (conn->outgoingBytesQueued() == 0) { + * if (conn->outgoing_bytes_queued() == 0) { * conn->reset(); // Safe to reset arena * } * * // Implement backpressure - * if (conn->outgoingBytesQueued() > MAX_BUFFER_SIZE) { + * if (conn->outgoing_bytes_queued() > MAX_BUFFER_SIZE) { * // Stop adding more data until queue drains * } * * // Logging/monitoring - * metrics.recordQueueDepth(conn->get_id(), conn->outgoingBytesQueued()); + * metrics.recordQueueDepth(conn->get_id(), conn->outgoing_bytes_queued()); * ``` */ int64_t outgoing_bytes_queued() const {