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

perf: cache computations in WithRequestDocumentRoot #1154

Merged
merged 6 commits into from
Nov 13, 2024

Conversation

dunglas
Copy link
Owner

@dunglas dunglas commented Nov 12, 2024

Alternative to #1152.

Improve performance by ~10% on my Mac with the default config.

@AlliBalliBaba
Copy link
Collaborator

In the meantime, here are some quick benchmarks to put you at ease 😄

Docker Linux amd64 20 CPU cores i9 wrk -t4 -c180 -d30 http://localhost/worker-with-watcher.php

In dunglas/frankenphp:1.25
php_server 40 threads: ~52000 RPS
php 40 threads: ~70000 RPS
php 8 threads: ~69000 RPS

In dunglas/frankenphp:1.3
php_server 40 threads: ~66000 RPS
php 40 threads: ~93000 RPS
php 8 threads (ideal): ~122000 RPS

The benchmark script is the one in testdata/worker-with-watcher.php. This doesn't capture all performance improvements though. Improvements to the $_SERVER import scale linearly with the size of the environment. And dispatching to workers in order should improve IO with external services (hard to quantify unless you're benchmarking a prod environment - which I plan to do with k6 and AWS ECS)

Copy link
Contributor

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's smart. Not sure why Go std lib doesn't do this already. (Can the wd change?)

@dunglas
Copy link
Owner Author

dunglas commented Nov 12, 2024

@AlliBalliBaba thank you very much!!

@mholt the working directory can change if the chdir syscall is used (or os.Chdir directly, in Go), that's why os.Getwd() cannot cache the value: https://www.man7.org/linux/man-pages/man2/chdir.2.html

@mholt
Copy link
Contributor

mholt commented Nov 12, 2024

Ah... I forgot about that. Thanks

@dunglas dunglas merged commit 843d199 into main Nov 13, 2024
46 checks passed
@dunglas dunglas deleted the perf/cache-WithRequestDocumentRoot-values branch November 13, 2024 06:10
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

Successfully merging this pull request may close these issues.

3 participants