Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[PropertyAccess] speed up accessing object properties#29999

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromxabbuh:pr-29405
Jan 30, 2019

Conversation

@xabbuh
Copy link
Member

@xabbuhxabbuh commentedJan 27, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#28926,#29405
LicenseMIT
Doc PR

I propose to improve the performance of theObjectNormalizer by not adding a new interface to the PropertyAccess component, but by adding some shortcut for cases where we know that we do not need to perform all checks. The added benefit is that this will not only speed up theObjectNormalizer class, but will be available for every consumer of thePropertyAccessor without having to adapt to a new API.

TODO:

fbourigault, javiereguiluz, DavidBadura, dunglas, and ogizanagi reacted with heart emoji
@fbourigault
Copy link
Contributor

fbourigault commentedJan 27, 2019
edited
Loading

As this provide almost identical performance boost (~ 20/30% perf improvement). I would prefer merging this and do further profiling to improve serializer performance.

self::VALUE =>$objectOrArray,
];

if (\is_object($objectOrArray) &&false ===strpos((string)$propertyPath,'.') &&false ===strpos((string)$propertyPath,'[')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (\is_object($objectOrArray) &&false ===strpos((string)$propertyPath,'.') &&false ===strpos((string)$propertyPath,'[')) {
if (\is_object($objectOrArray) &&false ===strpbrk((string)$propertyPath,'.[')) {

fbourigault, xabbuh, and vudaltsov reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Updated, though I wonder if usingstrcspn() and comparing that withstrlen() would be better in that it doesn't required to copy a string.

Copy link
Contributor

Choose a reason for hiding this comment

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

According tohttps://blackfire.io/profiles/compare/f5b0113a-fcae-41cc-9b83-3bdd48c8bcf5/graph usingstrpbrk is faster thanstrcspn +strlen.

@fbourigault
Copy link
Contributor

Here is a profile of this PR (with@ostrolucky suggestions ; singlestrpbrk is slightly faster than twostrpos) vs master :https://blackfire.io/profiles/compare/487eef43-6de6-4e82-954d-a08dc7c90e65/graph

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commitef7876e intosymfony:masterJan 30, 2019
fabpot added a commit that referenced this pull requestJan 30, 2019
…(xabbuh)This PR was merged into the 4.3-dev branch.Discussion----------[PropertyAccess] speed up accessing object properties| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#28926,#29405| License       | MIT| Doc PR        |I propose to improve the performance of the `ObjectNormalizer` by not adding a new interface to the PropertyAccess component, but by adding some shortcut for cases where we know that we do not need to perform all checks. The added benefit is that this will not only speed up the `ObjectNormalizer` class, but will be available for every consumer of the `PropertyAccessor` without having to adapt to a new API.TODO:- [ ] confirm that these changes indeed introduce the same benefit as#29405 doing an actual benchmarkCommits-------ef7876e speed up accessing object properties
@xabbuhxabbuh deleted the pr-29405 branchJanuary 30, 2019 13:06
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@dunglasdunglasdunglas approved these changes

+3 more reviewers

@ostroluckyostroluckyostrolucky left review comments

@fbourigaultfbourigaultfbourigault approved these changes

@vudaltsovvudaltsovvudaltsov approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

8 participants

@xabbuh@fbourigault@fabpot@dunglas@ostrolucky@vudaltsov@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp