summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2017-09-09 00:36:48 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-09-09 00:36:48 +0200
commit745a90dc84339774a37fddff480dd60c69f4cc2a (patch)
treeb856c29bd9fb13f31c3349866f2de9624bf56a3e /src
parent1105a14bccefb48a0e264fe19190c39629259338 (diff)
downloadminetest-745a90dc84339774a37fddff480dd60c69f4cc2a.tar.gz
minetest-745a90dc84339774a37fddff480dd60c69f4cc2a.tar.bz2
minetest-745a90dc84339774a37fddff480dd60c69f4cc2a.zip
Server: Calculate maximal total block sends dynamically (#6393)
The block sends per client is 1/2 when reaching the maximal player count.
Diffstat (limited to 'src')
-rw-r--r--src/clientiface.h5
-rw-r--r--src/defaultsettings.cpp1
-rw-r--r--src/server.cpp12
-rw-r--r--src/serverenvironment.h1
4 files changed, 9 insertions, 10 deletions
diff --git a/src/clientiface.h b/src/clientiface.h
index 4d61ae74e..4850b0c2a 100644
--- a/src/clientiface.h
+++ b/src/clientiface.h
@@ -272,10 +272,7 @@ public:
*/
void ResendBlockIfOnWire(v3s16 p);
- s32 SendingCount()
- {
- return m_blocks_sending.size();
- }
+ u32 getSendingCount() const { return m_blocks_sending.size(); }
// Increments timeouts and removes timed-out blocks from list
// NOTE: This doesn't fix the server-not-sending-block bug
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 212bc6208..2ddd5a43b 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -298,7 +298,6 @@ void set_default_settings(Settings *settings)
settings->setDefault("strict_protocol_version_checking", "false");
settings->setDefault("player_transfer_distance", "0");
settings->setDefault("max_simultaneous_block_sends_per_client", "10");
- settings->setDefault("max_simultaneous_block_sends_server_total", "40");
settings->setDefault("time_send_interval", "5");
settings->setDefault("default_game", "minetest");
diff --git a/src/server.cpp b/src/server.cpp
index 7bae69d55..c5b7bbd79 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2181,7 +2181,7 @@ void Server::SendBlocks(float dtime)
std::vector<PrioritySortedBlockTransfer> queue;
- s32 total_sending = 0;
+ u32 total_sending = 0;
{
ScopeProfiler sp2(g_profiler, "Server: selecting blocks for sending");
@@ -2195,7 +2195,7 @@ void Server::SendBlocks(float dtime)
if (!client)
continue;
- total_sending += client->SendingCount();
+ total_sending += client->getSendingCount();
client->GetNextBlocks(m_env,m_emerge, dtime, queue);
}
m_clients.unlock();
@@ -2207,11 +2207,13 @@ void Server::SendBlocks(float dtime)
std::sort(queue.begin(), queue.end());
m_clients.lock();
- s32 max_blocks_to_send =
- g_settings->getS32("max_simultaneous_block_sends_server_total");
+
+ // Maximal total count calculation
+ // The per-client block sends is halved with the maximal online users
+ u32 max_blocks_to_send = (m_env->getPlayerCount() + g_settings->getU32("max_users")) *
+ g_settings->getU32("max_simultaneous_block_sends_per_client") / 4 + 1;
for (const PrioritySortedBlockTransfer &block_to_send : queue) {
- //TODO: Calculate limit dynamically
if (total_sending >= max_blocks_to_send)
break;
diff --git a/src/serverenvironment.h b/src/serverenvironment.h
index 9d84d7a48..0eabfc08f 100644
--- a/src/serverenvironment.h
+++ b/src/serverenvironment.h
@@ -342,6 +342,7 @@ public:
RemotePlayer *getPlayer(const u16 peer_id);
RemotePlayer *getPlayer(const char* name);
+ u32 getPlayerCount() const { return m_players.size(); }
static bool migratePlayersDatabase(const GameParams &game_params,
const Settings &cmd_args);