php / doc-en

English PHP documentation
503 stars 734 forks source link

Time counting is vague in documentation of set_time_limit #1914

Open marcomarsala opened 2 years ago

marcomarsala commented 2 years ago

This part of documentation

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

is vague. For example, waiting for a flock() call to return does count or not in time spent?

cmb69 commented 2 years ago

Well, flock() would be a stream operatoon, so according to the documentation it would not count the time spent waiting for it to return. I'm not sure, though, whether the documentation is correct. Fact is that max_execution_time is implemented via setitimer(), usually using ITIMER_PROF (except for CygWin and PASE). According to the man page:

This timer counts down against the total (i.e., both user and system) CPU time consumed by the process. (The measurement includes CPU time consumed by all threads in the process.)

(That raises the question how that works with ZTS builds.)