php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79896 slower processing of non-fatal errors using custom error handler (7.4.7+)
Submitted: 2020-07-25 06:17 UTC Modified: 2020-07-31 06:39 UTC
From: tony dot jin at sbumed dot org Assigned: cmb (profile)
Status: Closed Package: Performance problem
PHP Version: 7.4.8 OS: Windows Server 2016
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tony dot jin at sbumed dot org
New email:
PHP Version: OS:

 

 [2020-07-25 06:17 UTC] tony dot jin at sbumed dot org
Description:
------------
seeing 10-100x slower processing of non-fatal errors using custom error handler function on 7.4.7-7.4.8 vs. 7.4.0-7.4.6.

https://3v4l.org/WcFJK/perf#output

not a c programmer, but i wonder if it could be caused by the following 7.4.6 bug fix:

https://bugs.php.net/bug.php?id=79599

Test script:
---------------
<?php

// see https://3v4l.org/WcFJK/perf#output

// 2020.07.25

// performance hit processing non-fatal errors w/ custom error handler (e_notice, e_warning)
// affects versions 7.4.7 & 7.4.8

// array of seq. ints
$start = 3;
$number_of_values = 5000;
$seq_array = range($start, $start+$number_of_values-1);

// set error handler
function error_handler_fn($errno, $errstr, $errfile, $errline) {
    $dummy = '0';
    // print_r(implode(", ", Array($errno, $errstr, $errfile, $errline))."\n");
}
set_error_handler("error_handler_fn");

// array to index
$array = Array(1,2,3);

// run loop
$t1 = microtime(true);
foreach ($seq_array as $val) {

	$nothing = $array[$val]; // E_NOTICE (8) - try to index array at undefined index (performance issue)
	
	// $nothing2 = count(); // E_WARNING (2) - try to count nothing (similar performance issue)

}
$t2 = microtime(true);
$outmsg = "\n\nRun time: " . round(($t2-$t1)*1000.,2) . " milliseconds (" . phpversion() . ")";
print_r($outmsg);

?>

Expected result:
----------------
execution time comparable to 7.4.6 and earlier

Actual result:
--------------
execution time 10-100x longer on 7.4.7-7.4.8 than on 7.4.6 and earlier

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-25 12:05 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-07-25 12:05 UTC] cmb@php.net
I think that has been fixed in the meantime[1].  Could you please
try with PHP 7.4.9RC1[2]?

[1] <http://git.php.net/?p=php-src.git;a=commit;h=5795dfda93d1f60cce4731e2089ad5975a6c062f>
[2] <https://windows.php.net/qa#php-7.4>
 [2020-07-31 06:07 UTC] tony dot jin at sbumed dot org
-Status: Feedback +Status: Assigned
 [2020-07-31 06:07 UTC] tony dot jin at sbumed dot org
The performance issue seems to be resolved on 7.4.9 RC1.
Thank you for the great news and fast turnaround!
 [2020-07-31 06:39 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-07-31 06:39 UTC] cmb@php.net
Fine! :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 11:01:37 2025 UTC