exercism / php-test-runner

GNU Affero General Public License v3.0
0 stars 6 forks source link

Increase memory limit for running PHP tests to 300MB #47

Closed dstockto closed 2 years ago

dstockto commented 2 years ago

This allows the robot names exercise to run where all names are generated first and then removed as they are used. That solution takes ~260-270MB to execute within PHPUnit. It can also allow for O(1) new name assignments. The solution that tracks used names will get exponentially slower as collisions become more and more likely. The tests for PHP only currently try 10k names. Other languages have tests that exercise the entire possible robot namespace.

neenjaw commented 2 years ago

This needs to be run by @ErikSchierboom, as there's no point adding this if it is overridden by the container orchestration done on production. On other tracks this situation (long running, large memory requirements) is often handled by skipping these tests from being run on on the website.

dstockto commented 2 years ago

FWIW, it's currently possible to set a new memory limit in the code with ini_set.

neenjaw commented 2 years ago

Yea, but if the docker container is set to 250 and it requests 300mb and hits it, the container will get shut down. So whatever @ErikSchierboom confirms is the memory limit of the containers, we should just set it to that.

dstockto commented 2 years ago

Understood - I know it's at least 300MB as that number works :)

ErikSchierboom commented 2 years ago

By default, the maximum amount of memory you can use is 3GB: https://github.com/exercism/tooling-invoker/blob/2eed6383791caa576637104999ea67a9d4f7793b/lib/tooling_invoker/configuration.rb#L31

dstockto commented 2 years ago

I think I'd probably set the php memory limit lower - if you're writing PHP that's using 3GB you're doing something pretty unusual I would think.

dstockto commented 2 years ago

I am good at 300MB for now. In production PHP I typically only do 128MB or less for web requests and 256MB for normal reports and 1024MB for analyzing large projects. I think the majority of the exercises won't be more than 64MB. The robot name exercise is slightly odd since it would only really be feasible as a CLI or long-running application, so allowing for more memory in that case makes sense. If you'd like to go higher, I am ok with that as well, but again, in most cases, using a ton of memory in PHP is probably a sign that something is going sideways.