Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Add separate setting for server sent commands per frame limit #11023

Merged
merged 1 commit into from
Jun 27, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/network/network_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ static void DistributeQueue(CommandQueue *queue, const NetworkClientSocket *owne
int to_go = UINT16_MAX;
#else
int to_go = _settings_client.network.commands_per_frame;
if (owner == nullptr) {
/* This is the server, use the commands_per_frame_server setting if higher */
to_go = std::max<int>(to_go, _settings_client.network.commands_per_frame_server);
}
#endif

CommandPacket *cp;
Expand Down
1 change: 1 addition & 0 deletions src/settings_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ struct NetworkSettings {
uint16 sync_freq; ///< how often do we check whether we are still in-sync
uint8 frame_freq; ///< how often do we send commands to the clients
uint16 commands_per_frame; ///< how many commands may be sent each frame_freq frames?
uint16 commands_per_frame_server; ///< how many commands may be sent each frame_freq frames? (server-originating commands)
uint16 max_commands_in_queue; ///< how many commands may there be in the incoming queue before dropping the connection?
uint16 bytes_per_frame; ///< how many bytes may, over a long period, be received per frame?
uint16 bytes_per_frame_burst; ///< how many bytes may, over a short period, be received?
Expand Down
9 changes: 9 additions & 0 deletions src/table/settings/network_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ min = 1
max = 65535
cat = SC_EXPERT

[SDTC_VAR]
var = network.commands_per_frame_server
type = SLE_UINT16
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_NETWORK_ONLY
def = 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the 16 based on? If a game script need to manage a few hundred/thousand towns/industries, will that be enough?
1024/16 = 64 => ~1 game day.

Alternatively, is a 16x improvement over 13.x behaviour enough? Or is that still too limiting?
Should the server maybe not have any limits, but only for game scripts?

Or it 16x a nice middle ground for some performance improvements of game scripts without immediately overwhelming? And is it up to the server owners to (occasionally) set this setting (much) higher for specific game scripts on especially large maps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an arbitrary value which is a compromise between allowing a larger throughput of commands from the server and not allowing a misbehaving game script to cause the network/game overall to grind to a halt.

Making it a setting avoids excessive bikeshed problems whilst providing better default behavior than currently.

min = 1
max = 65535
cat = SC_EXPERT

[SDTC_VAR]
var = network.max_commands_in_queue
type = SLE_UINT16
Expand Down