mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Add emerge queue limit configuration
This commit is contained in:
parent
206ec36c8e
commit
76217939e0
@ -184,6 +184,10 @@ void set_default_settings(Settings *settings)
|
|||||||
settings->setDefault("congestion_control_min_rate", "10");
|
settings->setDefault("congestion_control_min_rate", "10");
|
||||||
settings->setDefault("remote_media", "");
|
settings->setDefault("remote_media", "");
|
||||||
settings->setDefault("debug_log_level", "0");
|
settings->setDefault("debug_log_level", "0");
|
||||||
|
settings->setDefault("emergequeue_limit_total", "256");
|
||||||
|
settings->setDefault("emergequeue_limit_diskonly", "5");
|
||||||
|
settings->setDefault("emergequeue_limit_generate", "1");
|
||||||
|
|
||||||
// physics stuff
|
// physics stuff
|
||||||
settings->setDefault("movement_acceleration_default", "3");
|
settings->setDefault("movement_acceleration_default", "3");
|
||||||
settings->setDefault("movement_acceleration_air", "2");
|
settings->setDefault("movement_acceleration_air", "2");
|
||||||
|
@ -49,6 +49,10 @@ EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) {
|
|||||||
this->params = NULL;
|
this->params = NULL;
|
||||||
this->mapgen = NULL;
|
this->mapgen = NULL;
|
||||||
|
|
||||||
|
qlimit_total = g_settings->getU16("emergequeue_limit_total");
|
||||||
|
qlimit_diskonly = g_settings->getU16("emergequeue_limit_diskonly");
|
||||||
|
qlimit_generate = g_settings->getU16("emergequeue_limit_generate");
|
||||||
|
|
||||||
queuemutex.Init();
|
queuemutex.Init();
|
||||||
emergethread = new EmergeThread((Server *)gamedef);
|
emergethread = new EmergeThread((Server *)gamedef);
|
||||||
}
|
}
|
||||||
@ -98,23 +102,16 @@ bool EmergeManager::enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate
|
|||||||
if (allow_generate)
|
if (allow_generate)
|
||||||
flags |= BLOCK_EMERGE_ALLOWGEN;
|
flags |= BLOCK_EMERGE_ALLOWGEN;
|
||||||
|
|
||||||
//TODO:
|
|
||||||
// add logic to select which emergethread to add it to
|
|
||||||
// - one with the least queue contents?
|
|
||||||
// - if a queue is too full, move onto another one
|
|
||||||
// - use the peer id sometime
|
|
||||||
|
|
||||||
{
|
{
|
||||||
JMutexAutoLock queuelock(queuemutex);
|
JMutexAutoLock queuelock(queuemutex);
|
||||||
|
|
||||||
count = blocks_enqueued.size();
|
count = blocks_enqueued.size();
|
||||||
u16 queuelimit_total = 256;
|
if (count >= qlimit_total)
|
||||||
if (count >= queuelimit_total)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
count = peer_queue_count[peer_id];
|
count = peer_queue_count[peer_id];
|
||||||
u16 queuelimit_peer = allow_generate ? 1 : 5;
|
u16 qlimit_peer = allow_generate ? qlimit_generate : qlimit_diskonly;
|
||||||
if (count >= queuelimit_peer)
|
if (count >= qlimit_peer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
iter = blocks_enqueued.find(p);
|
iter = blocks_enqueued.find(p);
|
||||||
|
13
src/emerge.h
13
src/emerge.h
@ -45,15 +45,20 @@ struct BlockEmergeData {
|
|||||||
class EmergeManager {
|
class EmergeManager {
|
||||||
public:
|
public:
|
||||||
std::map<std::string, MapgenFactory *> mglist;
|
std::map<std::string, MapgenFactory *> mglist;
|
||||||
|
|
||||||
|
Mapgen *mapgen;
|
||||||
|
EmergeThread *emergethread;
|
||||||
|
|
||||||
//settings
|
//settings
|
||||||
MapgenParams *params;
|
MapgenParams *params;
|
||||||
|
u16 qlimit_total;
|
||||||
|
u16 qlimit_diskonly;
|
||||||
|
u16 qlimit_generate;
|
||||||
|
|
||||||
|
//block emerge queue data structures
|
||||||
JMutex queuemutex;
|
JMutex queuemutex;
|
||||||
std::map<v3s16, BlockEmergeData *> blocks_enqueued;
|
std::map<v3s16, BlockEmergeData *> blocks_enqueued;
|
||||||
std::map<u16, u16> peer_queue_count;
|
std::map<u16, u16> peer_queue_count;
|
||||||
Mapgen *mapgen;
|
|
||||||
EmergeThread *emergethread;
|
|
||||||
|
|
||||||
//biome manager
|
//biome manager
|
||||||
BiomeDefManager *biomedef;
|
BiomeDefManager *biomedef;
|
||||||
|
Loading…
Reference in New Issue
Block a user