Commit Graph

46 Commits

Author SHA1 Message Date
3be6665e3d AsyncWorker IDs now start from 0 instead of 1
this now matches their IDs in the AsyncWorker pool, as used by submitTask().
2018-06-11 11:58:24 +01:00
17607b8116 AsyncPool: added some void typehints 2018-06-11 10:41:40 +01:00
4c98d9d3ad AsyncPool: add a type doc to $size 2018-06-11 10:40:01 +01:00
7d5b3079bc AsyncPool: more documentation 2018-06-11 10:38:51 +01:00
88d83e0fca AsyncPool: Lazy-start AsyncWorkers when they are needed only
This changes how the AsyncPool works so that it does not immediately always start all of the workers in the pool.
Instead, workers will be started only when an idle worker was not found.
This allows for significant memory footprint reductions while idle.

In effect the async-workers setting in pocketmine.yml now dictates a _maximum_ pool size, not a fixed pool size.
2018-06-11 10:23:46 +01:00
3725bea3e5 AsyncPool: Slightly reduce worker memory usage with more conservative start options
this results in a memory footprint reduction of maybe 4MB for a total of 8 workers. Not much, but it's something.
2018-06-10 10:18:07 +01:00
c327b3d2c4 AsyncPool: be less dependent on Server in the code
The goal is to remove the Server things from here completely.
2018-06-08 20:08:23 +01:00
1a21041d00 AsyncPool: Parameterize worker memory limit instead of calling back into Server 2018-06-06 18:00:56 +01:00
d03f36ebee First look at splitting up AsyncPool and ServerScheduler
This commit contains quite a few breaking changes with respect to how AsyncTasks are handled. This is necessary to allow separation of the ServerScheduler and the AsyncPool, because in the future the ServerScheduler may be removed and instead there will be isolated per-plugin sync-task schedulers - but we cannot have every plugin with its own worker pool for memory usage reasons if nothing else.

The following things have changed:
- ServerScheduler: scheduleAsyncTask(), scheduleAsyncTaskToWorker(), getAsyncTaskPoolSize(), increaseAsyncTaskPoolSize() and similar methods have all been removed. Additionally the static \$WORKERS field has been removed.
- Server: added API method getAsyncPool(). This grants you direct access to the server's AsyncPool. Calls to getScheduler()->scheduleAsyncTask() and scheduleAsyncTaskToWorker() should be replaced with getAsyncPool()->submitTask() and submitTaskToWorker() respectively.
2018-05-30 12:20:10 +01:00
7fce48d38c AsyncPool: Unstack tasks from workers before entering the below loop 2018-05-30 11:17:16 +01:00
81957d133d AsyncTask: Rewrite how thread-local storage works, now non-dependent on Server or ServerScheduler
this implementation was god-awful bad and it was entirely avoidable to make it this complicated.

This utilizes the fact that pthreads treats static properties as thread-local. AsyncTask local storage now utilizes a \SplObjectStorage stored in an AsyncTask private static field.
2018-05-29 19:41:00 +01:00
982444949c Fixed typo in AsyncPool
asychronous -> asynchronous
2018-05-26 16:30:49 +01:00
c9bd60123b Scheduler: shutdown async pool properly instead of relying on ThreadManager 2018-05-09 19:49:12 +01:00
73e09392b6 Timings: Clean up some terrible code, move namespaces 2018-03-19 19:05:51 +00:00
e0d5c79848 Scheduler: Catch exceptions thrown from AsyncTask->onCompletion() 2018-02-27 11:33:16 +00:00
18b287c3ea AsyncTask: Remove cleanObject() and calls to it
This is no longer needed. Doing worker GC (via collect()) frees the allocated memory anyway, so this function is now redundant.
2018-01-30 16:45:49 +00:00
9902d29734 ServerScheduler::scheduleAsyncTask() returns the worker used (#1312) 2017-08-29 10:29:24 +01:00
7c212d3d53 Fix formatting issue in AsyncPool 2017-08-25 19:15:57 +01:00
17053389b0 Added memory limits for AsyncWorkers 2017-08-20 12:15:48 +01:00
8fc1501e89 Moar typehints 2017-07-14 08:52:27 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
568e2760f1 Collect workers when cancelling all tasks 2017-05-17 19:30:50 +01:00
00e6d6a6b1 Fixed AsyncTask memory leak (#922)
* Added PocketMine-TesterPlugin submodule with regression test
2017-05-17 15:43:44 +01:00
8404ce88bd Fixed pthreads crashes with progressUpdates 2016-11-12 18:30:55 +08:00
7861822a0f Fixed garbage AsyncTasks cannot be accessed 2016-11-12 17:47:07 +08:00
e6485c4734 Added AsyncTask progress update API 2016-11-12 17:31:59 +08:00
074583d104 Builtin thread-local object storage for AsyncTask (#1)
* Added AsyncTask::fetchLocal()
2016-11-06 22:02:53 +08:00
ddc140af5e Updated to new pthreads version, updated RakLib 2015-09-27 13:37:27 +02:00
0bcf639a98 Changed how exceptions work and are logged, throw proper exceptions on tasks 2015-09-18 12:03:24 +02:00
3ffdb8e552 Removed @deprecated classes, methods and properties, added some type hints 2015-09-12 17:10:11 +02:00
e137ac4c56 Base PHP7 work to make it "run" - READ NEXT LINES!
All plugins will need to bump the API if they want to use this.
NOTE THAT THIS IS NOT THE FINAL API 2.0.0 AND THAT THERE WILL BE MORE CHANGES.
To start updating, you might also want to read https://secure.php.net/manual/en/migration70.php and specifically https://secure.php.net/manual/en/migration70.incompatible.php

To compile PHP7 with some of the required dependencies, use https://gist.github.com/shoghicp/166ab26ce5cc7a390f45
ONLY LINUX IS TESTED, DO NOT ASK FOR OTHER PLATFORMS!

----- THIS VERSION IS NOT SUPPORTED -----

This version WILL crash randomly in unexpected places due to PHP7, pthreads, PocketMine or cosmic rays.

Handle with care, and store under direct sunlight for the best performance.
2015-09-10 21:29:29 +02:00
60ab35774a Fix wrong size increasing code. 2015-07-24 15:14:17 +08:00
be9f5521e1 Fixed undefined index on async worker crash 2015-06-19 18:36:08 +02:00
33e312c7d0 Added extra memory reportings (heap, stack), stop tasks faster, added extra timeouts fro ServerKiller 2015-06-13 15:37:02 +02:00
1a1b8830a4 Added MemoryManager object watcher for object leak debugging, improved SPL Thread/Worker stopping, fixed some possible weak references crashing unexpectedly 2015-05-09 16:11:12 +02:00
fbdbac06cc New delayed teleporting system 2015-04-26 23:04:24 +02:00
fba12f2a13 Be sure that AsyncTask finish executing, fixes #2931 2015-04-25 17:52:57 +02:00
d4cae729c3 Added AsyncTasks timings 2015-04-24 17:21:39 +02:00
b2c25eaf36 Added MemoryManager, new memory properties, improved performance, updated RakLib, fixed misc. bugs 2015-04-18 20:13:52 +02:00
71657a2a4e Improved effects, threading changes 2015-04-08 17:31:06 +02:00
72c4c01542 Yay generation uses async tasks 2015-03-26 18:21:39 +01:00
11c13cd666 Implemented Threaded ClassLoader, improves class loading while on different threads (no need to synchronize states) 2015-03-14 15:22:13 +01:00
24c6cca664 Updated RakLib, fixed help message not showing command, added documentation to Plugin->getResource() 2015-01-14 17:23:16 +01:00
9c28f0a5be Decrease async worker task amount after crashed task 2015-01-05 02:41:14 +01:00
5bf5014b60 Added Async Task crash warning 2015-01-05 00:16:47 +01:00
692045d714 Improved threading and resource usage, new defaults 2015-01-02 18:46:39 +01:00