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

inline $other->getPrototype() to speedup equals() #4040

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Oct 14, 2018

as measured in #4026 we try to speedup equals() by inlinening the $this->getPrototype() call.

also we use FQCN for native functions, because equals() is called a lot.

this speedsup the process by 4-5%.

see https://blackfire.io/profiles/compare/f4eefae8-6d09-4ab4-a833-f828d74a7b52/graph
image

@@ -156,34 +156,44 @@ public function clearChanged()
*/
public function equals($other, $caseSensitive = true)
{
$otherPrototype = $other instanceof self ? $other->getPrototype() : $other;
if ($other instanceof self) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I got all cases right. we need to double-check and maybe increase test-coverage in case this is not yet covered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, we see a failing test...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests fixed

}

if (array_key_exists(0, $otherPrototype) && $this->id !== $otherPrototype[0]) {
if (\array_key_exists(0, $other) && $this->id !== $other[0]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert backslashing.
we rely on native_function_invocation rule, that's it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this path is very very hot, and paying this additional namespace lookup here makes a difference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after #4041 its no longer measurable.

@staabm
Copy link
Contributor Author

staabm commented Oct 16, 2018

resubmitted with new merge base

#4047

@staabm staabm closed this Oct 16, 2018
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 this pull request may close these issues.

None yet

3 participants