Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Migrate from amphp/parallel-functions to amphp/parallel (#1216)
In #723 I disabled the parallelization by default as building the Box PHAR with parallelization was x1000 slower than without. Since then, a number of things changed in PHP-Scoper and in preparation to adapt the way the parallelization is done, a few things changed in Box too. I am not sure what element made a difference but according to PHPBench, enabling parallelization was reducing the build time from `13.932s` to `9.243s` so a ~33% speed improvement. I however gave it more though I as thinking serializing closures is a bad idea of a source of too many problems. Currently using parallelization in Box results in errors due to data being `readonly`. I do not remember exactly in what part `laravel/serializable-closure` messes up but I also remembered it was a limitation of the library (and in fairness, the library is really not at fault, it tries really hard to hack its way through to patch a very annoying PHP limitation, so it does what it can). But I kept finding those issues too annoying and I think the solution is also quite simple: to use AMPHP at a level lower which would avoid to have to serialize closures altogether. Closes #552. Closes #602 (the memory issue seems gone according to the PHPBench results). Closes #1160 (superseded). With those changes, we get the following results: | subject | memory | mode | rstdev | stdev | | - | - | - | - | - | | with PHP-Scoper; no parallel processing | 940.391mb | 13.932s | ±0.88% | 122.973ms | | with PHP-Scoper; parallel processing | 47.957mb | 6.668s | ±0.64% | 42.899ms | **In other words the parallelization goes from `9.243s` to `6.668s`, so a further ~28% improvement making it ~52% faster than without parallelization.**
- Loading branch information