dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.96k stars 244 forks source link

perf: Remove all Cgo handles #1071

Closed AlliBalliBaba closed 1 month ago

AlliBalliBaba commented 1 month ago

This PR aims to improve handle performance as discussed in #934

Instead of optimizing handles, they are completely removed and replaced by passing the index of the current thread This makes it so we can store a slice of phpThreads on the go side and have more potential control over thread creation/destruction/metrics. The performance impacts are similar to #934.

A quick worker benchmark: wrk -t 4 -c 150 -d 60 http://localhost:8124 on WSL bookworm-Docker 20 CPU cores 40 threads

Note that this benchmark was done with php_import_environment_variables disabled (I plan to address it in a separate PR).

This PR comes with some necessary refactoring (especially in worker.go) so I hope it doesn't conflict too much with other potential PRs.

AlliBalliBaba commented 1 month ago

I'll reopen this pull request from a different branch, seems like 'main' didn't merge correctly