Skip to content

Performance: Inline the object type check in change set computation - #12791

Merged
GromNaN merged 1 commit into
doctrine:3.8.xfrom
GromNaN:skip-db-comparison-for-scalar-fields
Nov 15, 2026
Merged

GromNaN merged 1 commit into
doctrine:3.8.xfrom
GromNaN:skip-db-comparison-for-scalar-fields

Conversation

@GromNaN

@GromNaN GromNaN commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

#12753 calls isSameConvertedDatabaseValue() for every mapped field whose value differs. The is_object() guards make the method cheap, but the call itself is not: method lookup, call frame and argument passing are paid on the hottest path of the UnitOfWork.

The check is now inlined at both call sites. is_object() compiles to a single ZEND_TYPE_CHECK opcode (Z_TYPE_P(value) != IS_OBJECT), so the && chain short-circuits for scalar values without any call. The method takes object parameters, and the field mapping check stays inside for the to-one associations walked by recomputeSingleEntityChangeSet().

@GromNaN
GromNaN force-pushed the skip-db-comparison-for-scalar-fields branch from b18b590 to ea275a8 Compare November 14, 2026 20:27
@GromNaN GromNaN added this to the 3.8.1 milestone Nov 14, 2026
@GromNaN GromNaN added the Bug label Nov 14, 2026
@GromNaN
GromNaN marked this pull request as ready for review November 14, 2026 20:37
@GromNaN
GromNaN requested a review from beberlei November 14, 2026 20:37
@GromNaN GromNaN changed the title Skip database value comparison for scalar fields Performance regression: Skip database value comparison for scalar fields Nov 14, 2026
@GromNaN GromNaN changed the title Performance regression: Skip database value comparison for scalar fields Performance: Skip database value comparison for scalar fields Nov 14, 2026
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Note

Greptile reviews are for Doctrine maintainers as a first filter, do not start fixing all the issues immediately unless you think they make sense. A maintainer will give you a green light on this PR for further development or rejection.

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Moves is_object() checks to both callers so scalar fields skip the comparison helper.

  • Scalar fields skip the database-value helper during change checks.

Reviews (1) · Last reviewed commit: "Skip database value comparison for scala..." · Reviewed by Greptile

@GromNaN
GromNaN requested review from greg0ire and mpdude November 14, 2026 20:51
@GromNaN
GromNaN enabled auto-merge (squash) November 14, 2026 20:52
@GromNaN GromNaN changed the title Performance: Skip database value comparison for scalar fields Inline the object type check in change set computation Nov 14, 2026
@GromNaN GromNaN changed the title Inline the object type check in change set computation Performance: Inline the object type check in change set computation Nov 14, 2026

@mpdude mpdude left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know almost nothing about those engine internals, so I would not have spotted the optimization potential or need myself… From my userland-only perspective, a comment at the call sites or method header would be helpful, pointing out why it’s designed that way

@GromNaN
GromNaN merged commit 90d3957 into doctrine:3.8.x Nov 15, 2026
38 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants