Remove epoll instances config

This commit is contained in:
2025-09-12 17:58:40 -04:00
parent 2b8f095d27
commit cd2e15677a
5 changed files with 7 additions and 28 deletions

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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

View File

@@ -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");

View File

@@ -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<Message, WaitStrategy::WaitIfStageEmpty, 1> pipeline{10};
EchoHandler handler{pipeline};