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

compile & work on new releases #329

Open
HASTJI opened this issue Nov 5, 2024 · 9 comments
Open

compile & work on new releases #329

HASTJI opened this issue Nov 5, 2024 · 9 comments

Comments

@HASTJI
Copy link

HASTJI commented Nov 5, 2024

Is it possible to compile your extension from source to dll from newest release 1.2.5? I already tried to do it, but there is no command in configure for "--enable-parallel=shared", only "--with-parallel" and it not providing any .dll for windows php using. It's only display that:

изображение

If i try to use "--with-parallel" - It configure and successfully nmake, but there is no any .dll in release folder for Parallel.

Also there can be a bug or error(now I'm using older 1.2.4 dll), but is it okay that if when example script is running as regular site page - it just shutdown and page is not reachable? If I directly call it from php.exe - it output this:

изображение

This is also seems a bit not too close to what I must see in according to readme (.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*)
Using Apache 2.4.54 and php as module of it.

@cmb69
Copy link
Collaborator

cmb69 commented Nov 5, 2024

On Windows there is indeed only --with-parallel, but if you need to, you can pass --with-parallel=shared. Assuming you are doing an in-tree build (that is you have parallel in the ext/ folder of PHP 8.3), you may need to do the latter. Otherwise parallel will be built into php8ts.dll.

You may also consider to wait some time; I'm pretty sure that DLLs will be available on https://pecl.php.net/package/parallel in due course. Or if you just want to do some testing, you can also try the DLLs from https://github.com/krakjoe/parallel/actions/runs/11683197031?pr=330 (not for production use).

@HASTJI
Copy link
Author

HASTJI commented Nov 5, 2024

And what about output from second part of my question? I already asked several people with different php and apache versions on windows and all of then said that on regular page parallel lib is not working at all and page not loading, but in cli mode it displays only response in that way as it displayed on my second screenshot in first post. It seems like it must not work with php which is a module of apache? Or there must be another prefered configuration for that lib for enable to run? For example nginx or php-fpm, etc?

UPD It feels like it waits until the second "For" cycle is completely finished, only then it starts the first "run" and "For" cycle inside it, after which it waits until it finishes working, and so on several times in a circle, instead of the standard alternation of workers.

@cmb69
Copy link
Collaborator

cmb69 commented Nov 5, 2024

I already asked several people with different php and apache versions on windows and all of then said that on regular page parallel lib is not working at all and page not loading, […]

Well, look into the log file. Possibly, pthreadVC3.dll is not found, because it's not in the PATH where Apache looks. You can use deplister.exe (from any of the official PHP Windows builds), and exec() it. But maybe the extension is crashing for whatever reason. https://bugs.php.net/bugs-generating-backtrace-win32.php may be helpful in this case.

It feels like it waits until the second "For" cycle is completely finished, only then it starts the first "run" and "For" cycle inside it, after which it waits until it finishes working, and so on several times in a circle, instead of the standard alternation of workers.

The example output is just how it might look like. What you get is completely reasonable (there need to be 500 dots and 500 stars; order is not predictable; that's up to the system thread scheduler). You can add usleep(1) to both loops to get a more regular pattern. Or instead of usleep(1) use for ($j = 0; $j < 10000; $j++) or something.

@HASTJI
Copy link
Author

HASTJI commented Nov 5, 2024

deplister:

>deplister.exe "V:\Apache\modules\php\PHP8.3\ext\php_parallel.dll"
php8ts.dll,OK
pthreadVC3.dll,OK
VCRUNTIME140.dll,OK
api-ms-win-crt-heap-l1-1-0.dll,NOTFOUND
api-ms-win-crt-string-l1-1-0.dll,NOTFOUND
api-ms-win-crt-runtime-l1-1-0.dll,NOTFOUND
KERNEL32.dll,OK

As for crash log - it runned process 20 times in cycle and created 20 500mb log files. After analyse each of them the error in all is the same:

изображение

(tried to past it as text, but all formatting is ruining. Sorry for big white flashbang :D)

I'm not quite sure that this log dump is helpful, but seems like it successfully locating all needed libs, but crashes at the moment when trying to start any thread

@cmb69
Copy link
Collaborator

cmb69 commented Nov 5, 2024

I'm not quite sure that this log dump is helpful, but seems like it successfully locating all needed libs, but crashes at the moment when trying to start any thread

It is at least helpful to know that there is a segfault. Thank you! I'll try to have a closer look soon.

Note that running deplister.exe on the command line can be irrelevant for Apache. In this case it doesn't matter (because we know that pthreadV3.dll is loaded), but for other cases you need to run deplister.exe via a PHP script requested from a client.

@HASTJI
Copy link
Author

HASTJI commented Nov 6, 2024

need to run deplister.exe via a PHP script

exec('deplister php_parallel.dll', $result);
print_r($result);
Array
(
    [0] => php8ts.dll,OK
    [1] => pthreadVC3.dll,OK
    [2] => VCRUNTIME140.dll,OK
    [3] => api-ms-win-crt-heap-l1-1-0.dll,NOTFOUND
    [4] => api-ms-win-crt-string-l1-1-0.dll,NOTFOUND
    [5] => api-ms-win-crt-runtime-l1-1-0.dll,NOTFOUND
    [6] => KERNEL32.dll,OK
)

Same result

@cmb69
Copy link
Collaborator

cmb69 commented Nov 7, 2024

I can reproduce the segfault; it happens at

https://github.com/php/php-src/blob/fb257ee83c405fecf449571bfcd1cc0fb4910336/sapi/apache2handler/sapi_apache2.c#L241

The problem is _tsrm_ls_cache is different for php_parallel.dll and php8apache2_4.dll. My knowledge about TLS in general and TSRM in particular is rather limited, so I'm unlikely able to solve this.

@HASTJI
Copy link
Author

HASTJI commented Nov 7, 2024

Looks like the main issue is on communication between php and apache, right? Is it means that this error can be solved if server platform will be changed to nginx or issue has a more complex problem?

It's a bit strange that no one has raised this issue before, because a lot of servers run Apache and it would have been noticed if it were widespread. Or maybe it's much simpler and people just don't use parallel on Windows...

@cmb69
Copy link
Collaborator

cmb69 commented Nov 9, 2024

Yeah, there should be no issues with (most) other SAPIs.

It's a bit strange that no one has raised this issue before, because a lot of servers run Apache and it would have been noticed if it were widespread. Or maybe it's much simpler and people just don't use parallel on Windows...

Well, maybe they don't use parallel directly with the Webserver module. It is conceivable that some use Apache as Webserver, but use another PHP process (likely on a different machine) to do some (background) processing using parallel.

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

No branches or pull requests

2 participants