Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased response time when increasing the value in ErrorHandler::memoryReserveSize #20030

Closed
antonshevelev opened this issue Oct 23, 2023 · 3 comments · Fixed by #20033
Closed

Comments

@antonshevelev
Copy link

antonshevelev commented Oct 23, 2023

What steps will reproduce the problem?

Set ErrorHandler to high ErrorHandler::memoryReserveSize.

What is the expected result?

Response time does not change.

What do you get instead?

Increased response time.

Additional info

yii\base\ErrorHandler::register

if ($this->memoryReserveSize > 0) {
	$this->_memoryReserve = str_repeat('x', $this->memoryReserveSize); //was in 2.0.45

	//at high values ​​MemoryReserveSize is slower than via str_repeat
	//Eg. MemoryReserveSize = 100000000 (100 MB), just for visible result
	$this->_memoryReserve = str_pad('', $this->memoryReserveSize, 'x'); //became starting from 2.0.46
}

upgrade from 2.0.45 to 2.0.48
10 MB reserved. memoryReserveSize = 10000000.
image

Q A
Yii version 2.0.48
PHP version 8.1.17
Operating system
@samdark
Copy link
Member

samdark commented Oct 23, 2023

Any idea why?

@rob006
Copy link
Contributor

rob006 commented Oct 23, 2023

It was introduced by #19402, and using str_pad() was supposed to be faster. But I just tested this and it is 10-20 times slower than str_repeat().

@rob006
Copy link
Contributor

rob006 commented Oct 23, 2023

#20033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants