Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121358 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 43084 invoked from network); 17 Oct 2023 17:39:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Oct 2023 17:39:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB83D180547 for ; Tue, 17 Oct 2023 10:39:24 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS2639 136.143.184.0/24 X-Spam-Virus: No X-Envelope-From: Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 17 Oct 2023 10:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697564362; cv=none; d=zohomail.com; s=zohoarc; b=XyFoRZMwgkxKmCSeEBvQ2MUe1JzJosJjYb3TiCseEbwb/urNt6J5eRIIx3Zb/bkks0Q2Ec4cJhEGDAK9Km+Z4HmzcudZ4AOxmaslCOK5TXU/gGMaCYvAq0SO5i90OfidPqE2MAvj2kk43TNyP2WuNtjHTU1SifSHo1Y8LamPnFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697564362; h=Content-Type:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=5cJeST9ZDSUWHGKwY8NbbN85XfZSx54gLRHoO8aiNAQ=; b=fVCkt4Bu0Somgb86Hw7g1/dW0POiD69bjbspPTPXJxuiPfuo7oXdaDxNuy657THth8y+AlNISVkOigoNMTPrrE6ejftHvcYiguN5zIvBrz4NUKOwsYOOS7hyF2woUqnyTUlJvckgDajnCgOdW5bARjOueAruQMt09LmTkZshPRM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=daniil.it; spf=pass smtp.mailfrom=daniil@daniil.it; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1697564362; s=daniil; d=daniil.it; i=daniil@daniil.it; h=Content-Type:Message-ID:Date:Date:MIME-Version:To:To:From:From:Subject:Subject:Message-Id:Reply-To:Cc; bh=5cJeST9ZDSUWHGKwY8NbbN85XfZSx54gLRHoO8aiNAQ=; b=jXhLm2U+eSH8Hz8AyG3qz//8SEoMr/JD0IhoKZxiglerL/Qe+knBEKmAyWfGKmd6 n7f/85lke9wYwgRf0jIj3bl3bytZrKFfemv0nGgWhyVt6JsgiBU7DkCYJFdqjU13jU1 FxAdvPlCEiR7Z7cteJHXnUXNIHJ8U+8Y8gcxkEwk= Received: from [192.168.69.233] (128.116.205.77 [128.116.205.77]) by mx.zohomail.com with SMTPS id 1697564360539456.800259754791; Tue, 17 Oct 2023 10:39:20 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------JzGhSspaYixHkDjAMwaGrJTw" Message-ID: Date: Tue, 17 Oct 2023 19:39:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: internals@lists.php.net X-ZohoMailClient: External Subject: Deprecate posix_times From: daniil@daniil.it (Daniil Gentili) --------------JzGhSspaYixHkDjAMwaGrJTw Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi everyone, I would like to submit an RFC (and related PR) to deprecate posix_times for PHP 8.4, removing it for PHP 9. There are multiple reasons to deprecate this function: 1) The values which times(2) returns are expressed as the number of clock ticks elapsed since the process was started: the frequency of the aforementioned clock varies from platform to platform, and PHP does not expose the sysconf(2) function, which is what should be used to fetch the clock frequency, invoking `sysconf(_SC_CLK_TCK)`. Thus, users have to deal with time values which **cannot be portably converted to microseconds**: this has actually bitten us @ work, where I recently found an ancient piece of code which incorrectly hardcoded the (undocumented) clock frequency of 100hz used on (most) Linux platforms: running the code on a Linux platform like ia64 [1], or any other POSIX OS which uses a different clock frequency would have silently reported an incorrect value, with no way to obtain the correct clock frequency from PHP. 2) Equivalent functionality is already provided by getrusage(), with a *much higher resolution*: *a.php:* $stat['utime'] * 10_000, // Assuming 100 hertz clock on x86 linux     'stime_times' => $stat['stime'] * 10_000, // Assuming 100 hertz clock on x86 linux     'utime_rusage' => $r['ru_utime.tv_usec'] + ($r['ru_utime.tv_sec'] * 1000_000),     'stime_rusage' => $r['ru_stime.tv_usec'] + ($r['ru_stime.tv_sec'] * 1000_000), ]; var_dump($res); *Result:* array(4) {   ["utime_times"]=>   int(160000)   ["stime_times"]=>   int(0)   ["utime_rusage"]=>   int(163672)   ["stime_rusage"]=>   int(4994) } As you can see, with a system time of ~5 milliseconds, posix_times() even returns 0, since the minimum duration that can be represented with a 100 hertz clock (the default on most Linux platforms) is 10 milliseconds. Waiting for feedback, kind regards, Daniil Gentili. [1]: https://github.com/bminor/glibc/blob/69239bd7a216007692470aa9d5f3658024638742/sysdeps/unix/sysv/linux/ia64/getclktck.c --------------JzGhSspaYixHkDjAMwaGrJTw--