dunglas / frankenphp

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

perf: use buffered chans for requests #1146

Closed withinboredom closed 2 weeks ago

withinboredom commented 2 weeks ago

Currently, the request channel isn't buffered. This means that if two requests come in concurrently, one is blocked even if two workers are immediately available. Ideally, the buffer would be equal to the number of threads, thus if you had four workers, four requests can be added to the channel immediately, without blocking.

AlliBalliBaba commented 2 weeks ago

This is probably a good idea 👍. Workers have their own request chan, so you should probably set the capacity there.

I imagine though that the goroutine would get blocked anyways when waiting for fc.done, so this will probably only have a small impact on performance.

withinboredom commented 2 weeks ago

Yeah, the reason I didn't provide benchmarks is because it is barely detectable. It is probably more detectable with more cores (I only have 16 to test with).

dunglas commented 2 weeks ago

Thanks @withinboredom