News for hackers. Stuff that matters.
Re:Whats New in PHP 8.2 by tgtweak on Monday April 25, 2022 @11:29AM (#31156245)
Just be a real cowboy and use pcntl_fork()

Partially not kidding - I've used this as far back as 2004 to build cron jobs that pull a dataset, split it into N subsets, then fork out into N children to process those subsets of data in parallel. It's certainly not fluid like tasks and it creates a lot of memory duplication if you fork AFTER your data is pulled, but it works surprisingly well. Parent thread can wait for children to finish and even message children through socket pairs (or pcntl_signal for very basic stuff). I agree that it would be nice to have a native abstraction for tasks with messaging and concurrency limits built in.

Re:Whats New in PHP 8.2 by hu3 on Monday April 25, 2022 @11:45AM (#31156504)
Fyi someone took pcntl_fork() in PHP seriously and made WorkerMan: https://github.com/walkor/workerman/blob/515ed41ac4fc51fc995...

A quick test got me 50k req/s HTTP "hello world" on my laptop.

The madlad even managed to place PHP in top 22 TechEmpower benchmark: https://i.imgur.com/6fKUpbV.png

Re:Whats New in PHP 8.2 by tgtweak on Friday April 29, 2022 @01:30PM (#31208211)
It's surprisingly fast. I think they extended it to create copy-on-write memory at fork time, which made it incredibly fast and low-overhead to fork.