Use Snooze to improve AsyncTask collection times

regardless of how long an async task takes to run, it will take a multiple of 50ms to get the result processed. This delay causes issues in some cases for stuff like generation, which causes locking of adjacent chunks, and async packet compression, which experiences elevated latency because of this problem.
This is not an ideal solution for packet compression since it will cause the sleeper handler to get hammered, but since it's already getting hammered by every packet from RakLib, I don't think that's a big problem.
This commit is contained in:
Dylan K. Taylor
2020-12-02 19:34:34 +00:00
parent 1775fb669b
commit 29f6ed3f68
6 changed files with 73 additions and 36 deletions

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\scheduler;
use PHPUnit\Framework\TestCase;
use pocketmine\snooze\SleeperHandler;
use pocketmine\utils\MainLogger;
use pocketmine\utils\Terminal;
use function define;
@ -44,7 +45,7 @@ class AsyncPoolTest extends TestCase{
Terminal::init();
@define('pocketmine\\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__, 3) . '/vendor/autoload.php');
$this->mainLogger = new MainLogger(tempnam(sys_get_temp_dir(), "pmlog"));
$this->pool = new AsyncPool(2, 1024, new \BaseClassLoader(), $this->mainLogger);
$this->pool = new AsyncPool(2, 1024, new \BaseClassLoader(), $this->mainLogger, new SleeperHandler());
}
public function tearDown() : void{