Skip to content

max_execution_time counts wall time on ZTS builds, CPU time elsewhere #25499

Open

Description

@nicolas-grekas

Description

max_execution_time should mean the same thing whatever the build. Today it counts CPU time on Linux, as the manual says ("database queries, etc. is not included"), but wall time on builds with Zend Max Execution Timers, on by default for ZTS on Linux and FreeBSD, since #10141 switched from CPU time during review.

This caught us by surprise moving a Symfony app from FPM to FrankenPHP: with the same php.ini, requests waiting for the lock of their session file started dying at 10 seconds, where FPM never counted that wait. A build option shouldn't redefine a setting everybody shares an understanding of.

timer_create() accepts CLOCK_THREAD_CPUTIME_ID on Linux, so these timers could count the CPU time of their thread, as setitimer() does everywhere else. A wall-time limit has its uses, but as its own setting, as proposed in https://wiki.php.net/rfc/max_execution_wall_time, not as a different meaning of this one.

WDYT?

Activity

  1. NattyNarwhal commented on Nov 17, 2026

    @NattyNarwhal
    Member

    Note that some platforms can only do wall time regardless, it's a bit of a mess:

    #if defined(__CYGWIN__) || defined(__PASE__)

    Then you have hard timeout in NTS but not ZTS!

    FWIW, I think wall time probably makes more sense since it's easier to reason about with, and a lot of timeouts are going to be spent waiting on i.e. remote database servers, where you're waiting on reads/writes.

  2. dunglas commented on Nov 17, 2026

    @dunglas
    Member

    We discussed that extensively when I introduced Zend Max Execution Timers, and IIRC, the historical behavior of counting CPU-time was there only because legacy reasons, but has never been wanted/intended.

    IMHO the long term goal should be to move on wall time everywhere, not to add extra options.

    See also #13468

  3. dunglas commented on Nov 17, 2026

    @dunglas
    Member

    Also, IIRC, @arnaud-lb and @bukka worked on a POC adding signal-less timeouts support for all platforms, but I don't know the status of this work.

  4. nicolas-grekas commented on Nov 17, 2026

    @nicolas-grekas
    ContributorAuthor

    I think trying to redefine the definition used by the vast majority of the ecosystem is a mistake, especially on a niche platform - ZTS and its derivates are niche let's be honest about this.
    I'd rather write the de facto definition in plain text somewhere as the only valid one and introduce another concept if we want wall-time limit.

  5. dunglas commented on Nov 17, 2026

    @dunglas
    Member

    This has been extensively discussed here: https://externals.io/message/118859

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions