diff --git a/src/config.cpp b/src/config.cpp index 091df57..3a710a7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -109,22 +109,13 @@ void ConfigParser::parse_server_config(const auto &toml_data, parse_field(srv, "max_request_size_bytes", config.max_request_size_bytes); parse_field(srv, "io_threads", config.io_threads); - // Set epoll_instances default to io_threads if not explicitly configured - bool epoll_instances_specified = srv.contains("epoll_instances"); - if (!epoll_instances_specified) { - config.epoll_instances = config.io_threads; - } else { - parse_field(srv, "epoll_instances", config.epoll_instances); - } + // epoll_instances removed - now 1:1 with io_threads parse_field(srv, "event_batch_size", config.event_batch_size); parse_field(srv, "max_connections", config.max_connections); parse_field(srv, "read_buffer_size", config.read_buffer_size); - // Clamp epoll_instances to not exceed io_threads - if (config.epoll_instances > config.io_threads) { - config.epoll_instances = config.io_threads; - } + // epoll_instances validation removed - now always equals io_threads }); } @@ -213,15 +204,7 @@ bool ConfigParser::validate_config(const Config &config) { valid = false; } - if (config.server.epoll_instances < 1 || - config.server.epoll_instances > config.server.io_threads) { - std::cerr - << "Configuration error: server.epoll_instances must be between 1 " - "and io_threads (" - << config.server.io_threads << "), got " - << config.server.epoll_instances << std::endl; - valid = false; - } + // epoll_instances validation removed - now always 1:1 with io_threads if (config.server.event_batch_size < 1 || config.server.event_batch_size > 10000) { diff --git a/src/config.hpp b/src/config.hpp index c022fb3..6f499de 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -40,10 +40,8 @@ struct ServerConfig { /// Maximum size in bytes for incoming HTTP requests (default: 1MB) int64_t max_request_size_bytes = 1024 * 1024; /// Number of I/O threads for handling connections and network events + /// Each I/O thread gets its own dedicated epoll instance int io_threads = 1; - /// Number of epoll instances to reduce epoll_ctl contention (default: - /// io_threads, max: io_threads) - int epoll_instances = 1; /// Event batch size for epoll processing int event_batch_size = 32; /// Maximum number of concurrent connections (0 = unlimited) diff --git a/src/main.cpp b/src/main.cpp index f8d35c7..31ecd48 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -234,8 +234,7 @@ int main(int argc, char *argv[]) { std::cout << "Max request size: " << config->server.max_request_size_bytes << " bytes" << std::endl; std::cout << "I/O threads: " << config->server.io_threads << std::endl; - std::cout << "Epoll instances: " << config->server.epoll_instances - << std::endl; + std::cout << "Epoll instances: " << config->server.io_threads << std::endl; std::cout << "Event batch size: " << config->server.event_batch_size << std::endl; std::cout << "Max connections: " << config->server.max_connections diff --git a/src/server.cpp b/src/server.cpp index fee574b..dd03ff4 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -264,9 +264,9 @@ void Server::setup_shutdown_pipe() { void Server::create_epoll_instances() { // Create multiple epoll instances to reduce contention - epoll_fds_.resize(config_.server.epoll_instances); + epoll_fds_.resize(config_.server.io_threads); - for (int i = 0; i < config_.server.epoll_instances; ++i) { + for (int i = 0; i < config_.server.io_threads; ++i) { epoll_fds_[i] = epoll_create1(EPOLL_CLOEXEC); if (epoll_fds_[i] == -1) { perror("epoll_create1"); diff --git a/tests/test_server_connection_return.cpp b/tests/test_server_connection_return.cpp index 1752227..f619743 100644 --- a/tests/test_server_connection_return.cpp +++ b/tests/test_server_connection_return.cpp @@ -42,7 +42,6 @@ TEST_CASE( "Server correctly handles connection ownership transfer via pipeline") { weaseldb::Config config; config.server.io_threads = 1; - config.server.epoll_instances = 1; StaticThreadPipeline pipeline{10}; EchoHandler handler{pipeline};