mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Tuned CPU usage on main lop and RakLib
This commit is contained in:
parent
9604907566
commit
5b69f07a55
@ -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();
|
||||||
|
|
||||||
if(($ticks = $this->tick()) !== true){
|
|
||||||
++$lastLoop;
|
++$lastLoop;
|
||||||
if($lastLoop > 16 and $lastLoop < 128){
|
|
||||||
usleep(200);
|
if(($ticks = $this->tick()) !== true){
|
||||||
}elseif($lastLoop < 512){
|
if($lastLoop > 2 and $lastLoop < 16){
|
||||||
usleep(400);
|
|
||||||
}else{
|
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}elseif($lastLoop < 128){
|
||||||
|
usleep(2000);
|
||||||
}else{
|
}else{
|
||||||
$lastLoop = 0;
|
usleep(10000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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){
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 740c96f033322d99e8804bb1a0218abef0ef117a
|
Subproject commit 85237bba6b6290397f2e1346587518437b96933b
|
Loading…
x
Reference in New Issue
Block a user