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

Future plans for this package #4

Closed
kelunik opened this issue Dec 21, 2017 · 6 comments
Closed

Future plans for this package #4

kelunik opened this issue Dec 21, 2017 · 6 comments

Comments

@kelunik
Copy link

kelunik commented Dec 21, 2017

Hey,

what are the future plans for this package, given you have integrated amphp/parallel-functions into https://github.com/spatie/laravel-collection-macros instead of using this package?

Generally I'd recommend against using forks, because each forks retains the previous state, e.g. open files etc. While that's currently also true for all child processes opened by PHP, that might change in the future, and they're already better for most uses generic use cases right now, because they don't retain the memory allocated by the currently running process.

@brendt
Copy link
Contributor

brendt commented Dec 21, 2017

Hey @kelunik

We're actually going to move away from pcntl_fork and use symfony/process instead. We'll also be using signals instead of sockets for IPC. A work-in-progress implementation can be found here: https://github.com/spatie/async/tree/symfony-process.

Note that we don't see this package as an alternative to Amp, but rather a very lightweight way of managing dynamic generated child processes. We have some use cases in which the functionality of this package (once it's done) is sufficient. We're aiming for less overhead (also meaning less functionality), resulting in better performance. The most important differences between this package and amphp/parallel:

  • Better performance - based on very crude benchmarks, I'm going to do a lot more tests soon.
  • A different, more simple API.
  • Less functionality, actually just one thing.
  • PHP 7.1+ (we're using pcntl_async_signals).
  • A+ compliant Promises. (Though I'm not 100% sure whether Amp promises changed with v2?)

I plan on working on this more the next two weeks during the holidays, so we'll have a better idea of what we're going to do with this afterwards.

@kelunik
Copy link
Author

kelunik commented Dec 21, 2017

We're actually going to move away from pcntl_fork and use symfony/process instead.

Good to know! How well does symfony/process support Windows? Signals won't work there. Not sure whether this is a concern for you.

Do you plan to have your own Promise interface or are you going to use ReactPHP's interface? For A+ you will need some kind of event loop, because then() callbacks must always be executed asynchronously. ReactPHP only implements A, not A+.

@brendt
Copy link
Contributor

brendt commented Dec 21, 2017

Ah that was one more thing I forgot to mention: we're not concerned with Windows support 😊.

I was actually thinking about using using Guzzle promises, and to unwrap them in the await call. I haven't implemented the details yet, but I think that should work without an event loop.

So it's clear that it won't be really A+ right now, but in case we will ever expand on this package, I'd like to use promises right away, so we could go an even more asynchronous way if needed.

@kelunik
Copy link
Author

kelunik commented Dec 21, 2017

Have fun with Guzzle's promises. 😉 Unfortunately, they don't really interop with anything else, even if they claim that. The periodic timer they suggest just hogs the CPU. If you want interop with other promises, don't use Guzzle's.

@brendt
Copy link
Contributor

brendt commented Dec 21, 2017

Ok thanks for the tip! We're going to get this working first without promises and see from there :)

@brendt
Copy link
Contributor

brendt commented Jan 2, 2018

I've since blogged about use cases for this package: https://www.stitcher.io/blog/asynchronous-php

I'm going to close this issue for now.

@brendt brendt closed this as completed Jan 2, 2018
@sayanb sayanb mentioned this issue Jan 10, 2019
TheTechsTech added a commit to symplely/spawn that referenced this issue Dec 15, 2021
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