Warn if max_packets_per_iteration reduced
Some checks failed
lua_api_deploy / build (push) Has been cancelled
macos / build (push) Has been cancelled
whitespace_checks / trailing_whitespaces (push) Has been cancelled
whitespace_checks / tabs_lua_api_files (push) Has been cancelled
linux / gcc_14 (push) Has been cancelled
linux / clang_7 (push) Has been cancelled
linux / clang_18 (push) Has been cancelled
linux / clang_11 (PROMETHEUS=1) (push) Has been cancelled
android / build (push) Has been cancelled
cpp_lint / clang_tidy (push) Has been cancelled
lua_lint / Compile and run multiplayer tests (push) Has been cancelled
lua_lint / Builtin Luacheck and Unit Tests (push) Has been cancelled
linux / gcc_7 (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (32) (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (64) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x64 generator:-G'Visual Studio 16 2019' -A x64 vcpkg_triplet:x64-windows], portable) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x86 generator:-G'Visual Studio 16 2019' -A Win32 vcpkg_triplet:x86-windows], portable) (push) Has been cancelled

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

View File

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

View File

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