Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

PB-439 Make thread pool workers configurable #302

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions configs/example-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
host = "localhost"
# (Optional) Port to listen on for incoming gRPC connections
port = 50051
# (Optional) The maximum number of gRPC thread pool workers
thread_pool_workers = 10

# (Optional)
[server.grpc_options]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def server_sample():
"grpc.max_receive_message_length": -1,
"grpc.max_send_message_length": -1,
},
"thread_pool_workers": 11,
}


Expand Down Expand Up @@ -122,11 +123,11 @@ def test_load_valid_config(config_sample): # pylint: disable=redefined-outer-na

assert config.server.host == "localhost"
assert config.server.port == 50051

assert config.server.grpc_options == [
("grpc.max_receive_message_length", -1),
("grpc.max_send_message_length", -1),
]
assert config.server.thread_pool_workers == 11

assert config.ai.rounds == 1
assert config.ai.epochs == 1
Expand Down
3 changes: 3 additions & 0 deletions xain_fl/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def log_level(key: str) -> Schema:
lambda opt: list(opt.items()),
error=error("server.grpc_options", "valid gRPC options"),
),
Optional("thread_pool_workers", default=10): positive_integer(
"server.thread_pool_workers"
),
}
)

Expand Down
3 changes: 2 additions & 1 deletion xain_fl/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def serve(coordinator: Coordinator, server_config: ServerConfig) -> None:

"""
server = grpc.server(
futures.ThreadPoolExecutor(max_workers=10), options=server_config.grpc_options
futures.ThreadPoolExecutor(max_workers=server_config.thread_pool_workers),
options=server_config.grpc_options,
)
coordinator_pb2_grpc.add_CoordinatorServicer_to_server(
CoordinatorGrpc(coordinator), server
Expand Down