mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 08:56:15 +00:00
Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called. When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace. This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified. However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement. But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations. We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
This commit is contained in:
@ -25,6 +25,15 @@ namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_keys;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function get_class;
|
||||
use function spl_object_hash;
|
||||
use function time;
|
||||
use const PHP_INT_MAX;
|
||||
use const PTHREADS_INHERIT_CONSTANTS;
|
||||
use const PTHREADS_INHERIT_INI;
|
||||
|
||||
/**
|
||||
* Manages general-purpose worker threads used for processing asynchronous tasks, and the tasks submitted to those
|
||||
|
@ -25,6 +25,9 @@ namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\Collectable;
|
||||
use pocketmine\Server;
|
||||
use function is_scalar;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Class used to run async tasks in other threads.
|
||||
|
@ -26,6 +26,10 @@ namespace pocketmine\scheduler;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\Worker;
|
||||
use function error_reporting;
|
||||
use function gc_enable;
|
||||
use function ini_set;
|
||||
use function set_error_handler;
|
||||
|
||||
class AsyncWorker extends Worker{
|
||||
/** @var mixed[] */
|
||||
|
@ -25,6 +25,8 @@ namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\utils\Internet;
|
||||
use pocketmine\utils\InternetException;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Executes a consecutive list of cURL operations.
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\MemoryManager;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Task used to dump memory from AsyncWorkers
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use function file_put_contents;
|
||||
|
||||
class FileWriteTask extends AsyncTask{
|
||||
|
||||
/** @var string */
|
||||
|
@ -23,6 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use function gc_collect_cycles;
|
||||
use function gc_enable;
|
||||
|
||||
class GarbageCollectionTask extends AsyncTask{
|
||||
|
||||
public function onRun(){
|
||||
|
@ -29,6 +29,14 @@ use pocketmine\utils\Internet;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\utils\UUID;
|
||||
use pocketmine\utils\VersionString;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function json_encode;
|
||||
use function md5;
|
||||
use function microtime;
|
||||
use function php_uname;
|
||||
use function strlen;
|
||||
use const PHP_VERSION;
|
||||
|
||||
class SendUsageTask extends AsyncTask{
|
||||
|
||||
|
Reference in New Issue
Block a user