Skip to content

Coordination: Prepare for students code using PHP 8.3 #155

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

Closed
mk-mxp opened this issue Mar 5, 2024 · 6 comments
Closed

Coordination: Prepare for students code using PHP 8.3 #155

mk-mxp opened this issue Mar 5, 2024 · 6 comments

Comments

@mk-mxp
Copy link

mk-mxp commented Mar 5, 2024

For exercism/php#652 we need to have the representer ready to accept PHP 8.3 code from students. The representer itself may run on a different PHP version.

@homersimpsons Can you outline the required work to do here? An actionable list of tasks would be perfect, but any hints are welcome.

@homersimpsons
Copy link
Collaborator

@homersimpsons Can you outline the required work to do here? An actionable list of tasks would be perfect, but any hints are welcome.

To me there is nothing to do:

That said I could also update the base docker image of the representer so everything runs on PHP8.3

@mk-mxp
Copy link
Author

mk-mxp commented Mar 7, 2024

I will mark the presenter as ready for PHP8.3, as your additions most likely won't affect any solutions soon.

For running on PHP 8.3: Use XDEBUG_MODE=off for performance reasons. I found at many places, that there is a huge impact even for small programs against having the default mode.

@homersimpsons
Copy link
Collaborator

For the record, I did upgrade the runtime for the representer to PHP8.3.

I did not try to change XDEBUG settings nor looked into the 2 normalizations I did suggest above. So I will let this issue open for now.

@homersimpsons
Copy link
Collaborator

homersimpsons commented Apr 27, 2025

For running on PHP 8.3: Use XDEBUG_MODE=off for performance reasons. I found at many places, that there is a huge impact even for small programs against having the default mode.

I tried doing this, and it didn't lead to any significant change. Maybe I did it wrong though. My steps were:

  1. Copy-paste a solution multiple times in a file in order to create a big php file (~30_000 lines)
  2. Build a container and run it normally or with XDEBUG_MODE=off
  3. Used hyperfine to measure changes. Note that I set --cpus 0.5 for both commands to reduce computer noise (I believe)
❯ ./hyperfine 'docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output' 'docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp --env XDEBUG_MODE=off representer-base "toto" /solution /output'
Benchmark 1: docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output
  Time (mean ± σ):      1.740 s ±  0.103 s    [User: 0.012 s, System: 0.013 s]
  Range (min … max):    1.598 s …  1.961 s    10 runs
 
Benchmark 2: docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp --env XDEBUG_MODE=off representer-base "toto" /solution /output
  Time (mean ± σ):      1.737 s ±  0.098 s    [User: 0.012 s, System: 0.013 s]
  Range (min … max):    1.620 s …  1.938 s    10 runs
 
Summary
  docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp --env XDEBUG_MODE=off representer-base "toto" /solution /output ran
    1.00 ± 0.08 times faster than docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output

Note that running with XDEBUG_MODE=debug,coverage does not really change the results.

❯ ./hyperfine 'docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output' 'docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp --env XDEBUG_MODE=debug,coverage representer-base "toto" /solution /output'
Benchmark 1: docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output
  Time (mean ± σ):      1.536 s ±  0.021 s    [User: 0.011 s, System: 0.013 s]
  Range (min … max):    1.508 s …  1.573 s    10 runs
 
Benchmark 2: docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp --env XDEBUG_MODE=debug,coverage representer-base "toto" /solution /output
  Time (mean ± σ):      1.536 s ±  0.033 s    [User: 0.012 s, System: 0.013 s]
  Range (min … max):    1.491 s …  1.604 s    10 runs
 
Summary
  docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output ran
    1.00 ± 0.03 times faster than docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp --env XDEBUG_MODE=debug,coverage representer-base "toto" /solution /output

I also tried with adding a RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" in the Dockerfile:

❯ ./hyperfine 'docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output' 'docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-prod "toto" /solution /output'
Benchmark 1: docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output
  Time (mean ± σ):      1.559 s ±  0.019 s    [User: 0.013 s, System: 0.011 s]
  Range (min … max):    1.527 s …  1.585 s    10 runs
 
Benchmark 2: docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-prod "toto" /solution /output
  Time (mean ± σ):      1.550 s ±  0.033 s    [User: 0.013 s, System: 0.011 s]
  Range (min … max):    1.504 s …  1.602 s    10 runs
 
Summary
  docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-prod "toto" /solution /output ran
    1.01 ± 0.02 times faster than docker run --rm --network none --read-only --cpus 0.5 --mount type=bind,source="/home/foo/php-representer/solutions/bench-simple-cipher",destination=/solution --mount type=tmpfs,destination=/output --mount type=tmpfs,destination=/tmp representer-base "toto" /solution /output

I believe that this is because we are in CLI and hence those settings have close to 0 impact.

I also tried to run those with poop to get other metrics, but it always failed to run (I believe because of the quotes or the special --mount argument).

@mk-mxp
Copy link
Author

mk-mxp commented Apr 28, 2025

It's been a year since I was hit by the performance degradation and haven't looked into it lately. Seems to be gone now, that's good news!

@homersimpsons
Copy link
Collaborator

I'm closing this after #299:

  • "Remove the #[\Override] attribute", while probably relevant, it is unlikely that we see it in the wild yet.
  • For the XDEBUG settings, see the more lengthy discussion above.

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

No branches or pull requests

2 participants