Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Pool::submit #63

Open
JunoBoom opened this issue Sep 7, 2021 · 2 comments
Open

Slow Pool::submit #63

JunoBoom opened this issue Sep 7, 2021 · 2 comments

Comments

@JunoBoom
Copy link

JunoBoom commented Sep 7, 2021

Environment

  • PHP: PHP 7.4.16 (cli)
  • pthreads: Version => 3.2.1dev
  • OS: Linux Ubuntu

Summary

Pool::Submit takes around 0.02sec for each thread. Each iteration of my foreach loop takes 0.002seconds until getting to Pool::Submit line, where time increases 10fold for each iteration, going up from 0.002 to 0.02 average .

Reproducing Code

$ProfilesThreadsPool = new \Pool($ProfilesLimit);
$AllProfilesThreads = [];
$SelectedActivePool = $SelectedProfiles = [];

for ($j = 0; $j < count($OpenTasks); $j++) {
/// Lots of Random Code Before Submitting Thread///
///////////////////////////////////////////////////
$SelectedProfiles = array_merge($SelectedProfiles, array_column($ChunkedProfiles, 'id'));
$CurrentProfileThread = new MultiThreadProfiles($ChunkedProfiles, $ActiveProfile);
$AllProfilesThreads[] = $CurrentProfileThread;
$ProfilesThreadsPool->submit($CurrentProfileThread);
{

Expected Output

Expected thread creation time under 0.002sec

Actual Output

Each thread submit takes 0.02sec .

@JunoBoom
Copy link
Author

JunoBoom commented Sep 7, 2021

Enabling opcache.enable_cli=1 seems to partially have fixed the Pool::Submit slowness with some of the threads submitted but created a new issue :

zend_mm_heap corrupted
Segmentation fault

@dktapps
Copy link
Member

dktapps commented Sep 26, 2021

Hi, this fork of pthreads is specifically intended for PocketMine-MP usage, and PM doesn't use Pool, so this is unlikely to get fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants