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

Debugging usage #7

Open
theofidry opened this issue Feb 12, 2018 · 7 comments
Open

Debugging usage #7

theofidry opened this issue Feb 12, 2018 · 7 comments

Comments

@theofidry
Copy link

Moving my question from box-project/box#53 (comment) to here.

I think it would be good if it would be possible to easily switch from parallelMap() to a plain old array_map(), be it for debugging purposes or simply because in a special case parallelMap() is not working e.g. when the passed argument is not serializable.

Maybe an env variable would work, the inconvenient being it's gonna rely on global state, the benefit is would be easier and won't require much changes.

On the same token, the major downside I have with this library is the inability to use break points for the paralellised work. Would make it work?

If you have some insight regarding this that would be greatly appreciated, otherwise I'll try to give it a stab in the coming months :)

@trowski
Copy link
Member

trowski commented Feb 13, 2018

After giving this some thought, the correct place for a solution may in fact be in amphp/parallel (where you first opened the issue amphp/parallel#39).

We already use an environment variable (or constant) AMP_DEBUG to turn on certain debugging features in amphp/amp. I think a similar constant such as AMP_PARALLEL_DEBUG may be a good idea. What I'm thinking is for this flag to cause DefaultWorkerFactory to return a worker that uses a context that executes in the same process. This way breakpoints could be set within Task implementors (parallelMap() is executed by a class implementing Task). That class already uses another such flag, AMP_PHP_BINARY, that can be set to define a specific path to the PHP executable binary.

@rybakit
Copy link

rybakit commented Feb 13, 2018

I'm not sure if AMP_PARALLEL_DEBUG is really needed. At least PHPStorm allows you to debug multiple processes simultaneously, check this manual: https://confluence.jetbrains.com/display/PhpStorm/Simultaneous+debugging+sessions+with+PhpStorm. Works like a charm for me.

@theofidry
Copy link
Author

@rybakit mind to share you configuration? Because I can't it get working. Whenever the breakpoint is in a function executed by the worker in another process the breakpoint is never hit

@theofidry
Copy link
Author

I've just thought about it: @rybakit is kinda right. What is not working is a breakpoint inside the payload: I think it's because the function is serialiazed/unserialized it's no longer able to pick up where it's coming from :/

@kelunik
Copy link
Member

kelunik commented Mar 1, 2018

@theofidry Correct. You can implement a Task class instead and use the amphp/parallel API, then it should continue to work.

@theofidry
Copy link
Author

Wouldn't it be easier then to simply call the callable in parallel()?

As the main point here is to not serialize, if we were to try to use the works & co. still it means creating a new task & context to execute the task within the same process. That's a non-negligeable amount of work and I'm not sure there's any benefit in it. The point of this debugging mode is more being able to debug the callable not execute the whole amphp toolchain

@kelunik
Copy link
Member

kelunik commented Mar 1, 2018

Yes, that's definitely easier.

theofidry added a commit to theofidry/parallel-functions that referenced this issue Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants