Warn if max_packets_per_iteration reduced

This commit is contained in:
sfan5 2024-08-18 22:06:48 +02:00
parent 1380bf9b88
commit 8972c80d7d
2 changed files with 15 additions and 6 deletions

@ -2024,9 +2024,8 @@ max_simultaneous_block_sends_per_client (Maximum simultaneous block sends per cl
# This determines how long they are slowed down after placing or removing a node. # This determines how long they are slowed down after placing or removing a node.
full_block_send_enable_min_time_from_building (Delay in sending blocks after building) float 2.0 0.0 full_block_send_enable_min_time_from_building (Delay in sending blocks after building) float 2.0 0.0
# Maximum number of packets sent per send step, if you have a slow connection # Maximum number of packets sent per send step in the low-level networking code.
# try reducing it, but don't reduce it to a number below double of targeted # You generally don't need to change this, however busy servers may benefit from a higher number.
# client number.
max_packets_per_iteration (Max. packets per iteration) int 1024 1 65535 max_packets_per_iteration (Max. packets per iteration) int 1024 1 65535
# Compression level to use when sending mapblocks to the client. # Compression level to use when sending mapblocks to the client.

@ -59,14 +59,24 @@ static inline u8 readChannel(const u8 *packetdata)
/* Connection Threads */ /* Connection Threads */
/******************************************************************************/ /******************************************************************************/
#define MPPI_SETTING "max_packets_per_iteration"
ConnectionSendThread::ConnectionSendThread(unsigned int max_packet_size, ConnectionSendThread::ConnectionSendThread(unsigned int max_packet_size,
float timeout) : float timeout) :
Thread("ConnectionSend"), Thread("ConnectionSend"),
m_max_packet_size(max_packet_size), m_max_packet_size(max_packet_size),
m_timeout(timeout), m_timeout(timeout),
m_max_data_packets_per_iteration(g_settings->getU16("max_packets_per_iteration")) m_max_data_packets_per_iteration(g_settings->getU16(MPPI_SETTING))
{ {
SANITY_CHECK(m_max_data_packets_per_iteration > 1); auto &mppi = m_max_data_packets_per_iteration;
mppi = MYMAX(mppi, 1);
const auto mppi_default = Settings::getLayer(SL_DEFAULTS)->getU16(MPPI_SETTING);
if (mppi < mppi_default) {
warningstream << "You are running the network code with a non-default "
"configuration (" MPPI_SETTING "=" << mppi << "). "
"This is not recommended in production." << std::endl;
}
} }
void *ConnectionSendThread::run() void *ConnectionSendThread::run()
@ -769,7 +779,7 @@ void ConnectionSendThread::sendPackets(float dtime, u32 peer_packet_quota)
} }
} }
if (peer_packet_quota > 0) { if (peer_packet_quota > 0 && !stopRequested()) {
for (session_t peerId : peerIds) { for (session_t peerId : peerIds) {
PeerHelper peer = m_connection->getPeerNoEx(peerId); PeerHelper peer = m_connection->getPeerNoEx(peerId);
if (!peer) if (!peer)