mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Tuned CPU usage on main lop and RakLib
This commit is contained in:
@ -1743,15 +1743,15 @@ class Server{
|
|||||||
|
|
||||||
$this->logger->info("Done (" . round(microtime(true) - \pocketmine\START_TIME, 3) . 's)! For help, type "help" or "?"');
|
$this->logger->info("Done (" . round(microtime(true) - \pocketmine\START_TIME, 3) . 's)! For help, type "help" or "?"');
|
||||||
|
|
||||||
if(Utils::getOS() === "win"){ //Workaround less usleep() waste
|
//if(Utils::getOS() === "win"){ //Workaround less usleep() waste
|
||||||
$this->tickProcessorWindows();
|
// $this->tickProcessorWindows();
|
||||||
}else{
|
//}else{
|
||||||
$this->tickProcessor();
|
$this->tickProcessor();
|
||||||
}
|
//}
|
||||||
$this->forceShutdown();
|
$this->forceShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function tickProcessorWindows(){
|
/*private function tickProcessorWindows(){
|
||||||
$lastLoop = 0;
|
$lastLoop = 0;
|
||||||
while($this->isRunning){
|
while($this->isRunning){
|
||||||
foreach($this->interfaces as $interface){
|
foreach($this->interfaces as $interface){
|
||||||
@ -1763,14 +1763,14 @@ class Server{
|
|||||||
|
|
||||||
if(($ticks = $this->tick()) !== true){
|
if(($ticks = $this->tick()) !== true){
|
||||||
++$lastLoop;
|
++$lastLoop;
|
||||||
if($lastLoop > 128){
|
if($lastLoop > 8){
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$lastLoop = 0;
|
$lastLoop = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public function checkTicks(){
|
public function checkTicks(){
|
||||||
if($this->getTicksPerSecond() < 12){
|
if($this->getTicksPerSecond() < 12){
|
||||||
@ -1884,17 +1884,16 @@ class Server{
|
|||||||
}
|
}
|
||||||
$this->generationManager->handlePackets();
|
$this->generationManager->handlePackets();
|
||||||
|
|
||||||
|
++$lastLoop;
|
||||||
|
|
||||||
if(($ticks = $this->tick()) !== true){
|
if(($ticks = $this->tick()) !== true){
|
||||||
++$lastLoop;
|
if($lastLoop > 2 and $lastLoop < 16){
|
||||||
if($lastLoop > 16 and $lastLoop < 128){
|
|
||||||
usleep(200);
|
|
||||||
}elseif($lastLoop < 512){
|
|
||||||
usleep(400);
|
|
||||||
}else{
|
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
}elseif($lastLoop < 128){
|
||||||
|
usleep(2000);
|
||||||
|
}else{
|
||||||
|
usleep(10000);
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
$lastLoop = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function process(){
|
public function process(){
|
||||||
$this->interface->handlePacket();
|
return $this->interface->handlePacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function closeSession($identifier, $reason){
|
public function closeSession($identifier, $reason){
|
||||||
|
Submodule src/raklib updated: 740c96f033...85237bba6b
Reference in New Issue
Block a user