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

Improve performance by usingspl_object_id() on PHP 7.2+#267

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
SimonFrings merged 1 commit intoreactphp:1.xfromsamsonasik:use-spl-object-id
Oct 25, 2023

Conversation

@samsonasik
Copy link
Contributor

spl_object_id() is exists since php 7.2, I thinkspl_object_id() can be used when php version >= 7.2

Refs:

Same implementation in reactphp/http:

https://github.com/reactphp/http/blob/c6321978bfb82de979fe4dc28eb0c08bc34937ad/src/Io/RequestHeaderParser.php#L165

Benchmark

Beforecall in loop took: 13.639ms

https://3v4l.org/4rUL4

Aftercall in loop took: 4.835ms

https://3v4l.org/jKtO6

ace411 and XNicON reacted with thumbs up emoji
@samsonasik
Copy link
ContributorAuthor

it seems cause error in test:

➜  event-loop git:(use-spl-object-id) vendor/bin/phpunit tests/Timer/TimersTest.phpPHPUnit 9.6.11 by Sebastian Bergmann and contributors..F                                                                  2 / 2 (100%)Time: 00:01.009, Memory: 6.00 MBThere was 1 failure:1) React\Tests\EventLoop\Timer\TimersTest::testContainsFailed asserting that false is true./Users/samsonasik/www/event-loop/tests/Timer/TimersTest.php:37FAILURES!Tests: 2, Assertions: 2, Failures: 1.

@samsonasik
Copy link
ContributorAuthor

I see,$id need to be filled oncontains() method0221e0d

@samsonasik
Copy link
ContributorAuthor

@SimonFrings
Copy link
Member

Hey@samsonasik, thanks for your contribution 👍

I can see from your benchmark that using thespl_object_id() seems to be way more efficient thanspl_object_hash(). I'm curious if this also offers some performance improvements for this project, do you have some benchmarks using ReactPHP?

CI error seems unrelated

Regarding the CI error, the pecl/uv extension received a new v0.3.0 in June which is only compatible with 8+ (for reference see:https://pecl.php.net/package/uv) . I'll have a look at this 👍

samsonasik reacted with thumbs up emoji

@samsonasik
Copy link
ContributorAuthor

@samsonasik
Copy link
ContributorAuthor

@SimonFrings rebased 👍

@samsonasik
Copy link
ContributorAuthor

All green 🎉

@clueclue added this to thev1.5.0 milestoneOct 21, 2023
Copy link
Member

@clueclue left a comment

Choose a reason for hiding this comment

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

@samsonasik Thank you for looking into this and filing this PR! 👍

The changes LGTM and while I do not expect any significant changes in real-world use cases, I can confirm this does indeed improve performance slightly in some synthetic benchmarks:

$time php examples/92-benchmark-timers.php 1000000# new: ~3.2s# old: ~4.1s

Interestingly, I've also applied somewhat similar changes withreactphp/http#467 in the past.

May I ask you to squash your changes into a single commit so we can go ahead with this one?:shipit:

samsonasik reacted with thumbs up emoji
@clueclue changed the title[Performance] Use spl_object_id() when possibleImprove performance by usingspl_object_id() on PHP 7.2+Oct 21, 2023
@samsonasik
Copy link
ContributorAuthor

@clue I've squashed the changes into single commit 👍

Copy link
Member

@clueclue left a comment

Choose a reason for hiding this comment

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

@samsonasik Thanks for the update, changes LGTM! Keep it up!:shipit:

samsonasik reacted with thumbs up emojisamsonasik reacted with rocket emoji
Copy link
Member

@WyriHaximusWyriHaximus left a comment

Choose a reason for hiding this comment

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

@samsonasik Much appreciate putting the time and effort in this improvement 👍

samsonasik reacted with thumbs up emojisamsonasik reacted with rocket emoji
Copy link
Member

@SimonFringsSimonFrings left a comment

Choose a reason for hiding this comment

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

Nice work 👍

samsonasik reacted with thumbs up emojisamsonasik and devnix reacted with hooray emoji
@SimonFringsSimonFrings merged commit67f4642 intoreactphp:1.xOct 25, 2023
@samsonasiksamsonasik deleted the use-spl-object-id branchOctober 25, 2023 07:53
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@WyriHaximusWyriHaximusWyriHaximus approved these changes

@clueclueclue approved these changes

@SimonFringsSimonFringsSimonFrings approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

v1.5.0

Development

Successfully merging this pull request may close these issues.

4 participants

@samsonasik@SimonFrings@WyriHaximus@clue

[8]ページ先頭

©2009-2025 Movatter.jp