Rename ArenaAllocator -> Arena

This commit is contained in:
2025-09-05 17:57:04 -04:00
parent 46fe51c0bb
commit f56ed2bfbe
22 changed files with 267 additions and 279 deletions

View File

@@ -48,7 +48,7 @@ ninja test # or ctest
```
**Individual targets:**
- `./test_arena_allocator` - Arena allocator unit tests
- `./test_arena` - Arena allocator unit tests
- `./test_commit_request` - JSON parsing and validation tests
- `./test_http_handler` - HTTP protocol handling tests
- `./test_metric` - Metrics system tests
@@ -56,7 +56,7 @@ ninja test # or ctest
- `./test_server_connection_return` - Connection lifecycle tests
**Benchmarking:**
- `./bench_arena_allocator` - Memory allocation performance
- `./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
@@ -90,7 +90,7 @@ ninja test # or ctest
### Core Components
#### **Arena Allocator** (`src/arena_allocator.hpp`)
#### **Arena Allocator** (`src/arena.hpp`)
Ultra-fast memory allocator optimized for request/response patterns:
@@ -290,7 +290,7 @@ See [style.md](style.md) for comprehensive C++ coding standards and conventions.
- **Server Creation**: Always use `Server::create()` factory method - direct construction is impossible
- **Connection Creation**: Only the Server can create connections - no public constructor or factory method
- **Connection Ownership**: Use unique_ptr semantics for safe ownership transfer between components
- **Arena Allocator Pattern**: Always use `ArenaAllocator` for temporary allocations within request processing
- **Arena Allocator Pattern**: Always use `Arena` for temporary allocations within request processing
- **String View Usage**: Prefer `std::string_view` over `std::string` when pointing to arena-allocated memory
- **Ownership Transfer**: Use `Server::release_back_to_server()` for returning connections to server from handlers
- **JSON Token Lookup**: Use the gperf-generated perfect hash table in `json_tokens.hpp` for O(1) key recognition
@@ -375,7 +375,7 @@ class HttpHandler : public ConnectionHandler {
public:
void on_data_arrived(std::string_view data, std::unique_ptr<Connection>& conn_ptr) override {
// Parse HTTP request using connection's arena
ArenaAllocator& arena = conn_ptr->get_arena();
Arena& arena = conn_ptr->get_arena();
// Generate response
conn_ptr->append_message("HTTP/1.1 200 OK\r\n\r\nHello World");
@@ -468,7 +468,7 @@ public:
#### Arena-Based String Handling
```cpp
// Preferred: String view with arena allocation to minimize copying
std::string_view process_json_key(const char* data, ArenaAllocator& arena);
std::string_view process_json_key(const char* data, Arena& arena);
// Avoid: Unnecessary string copies
std::string process_json_key(const char* data);
@@ -513,13 +513,13 @@ ParseResult parse_commit_request(const char* json, CommitRequest& out);
### Build Targets
**Test Executables:**
- `test_arena_allocator` - Arena allocator functionality tests
- `test_arena` - Arena allocator functionality tests
- `test_commit_request` - JSON parsing and validation tests
- `test_metric` - Metrics system functionality tests
- Main server executable (compiled from `src/main.cpp`)
**Benchmark Executables:**
- `bench_arena_allocator` - Arena allocator performance benchmarks
- `bench_arena` - Arena allocator performance benchmarks
- `bench_commit_request` - JSON parsing performance benchmarks
- `bench_parser_comparison` - Comparison benchmarks vs nlohmann::json and RapidJSON
- `bench_metric` - Metrics system performance benchmarks