Improve performance by using spl_object_id() on PHP 7.2+#267
Improve performance by using spl_object_id() on PHP 7.2+#267SimonFrings merged 1 commit intoreactphp:1.xfrom
spl_object_id() on PHP 7.2+#267Conversation
|
it seems cause error in test: |
|
I see, |
|
Hey @samsonasik, thanks for your contribution 👍 I can see from your benchmark that using the
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 👍 |
|
Hi, we are using event-loop at rector, we use spl_object_id and it seems improve the performance, see related PR:. |
0221e0d to
5897873
Compare
|
@SimonFrings rebased 👍 |
|
All green 🎉 |
clue
left a comment
There was a problem hiding this comment.
@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.1sInterestingly, I've also applied somewhat similar changes with reactphp/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? ![]()
spl_object_id() on PHP 7.2+
5897873 to
4a8f6af
Compare
|
@clue I've squashed the changes into single commit 👍 |
clue
left a comment
There was a problem hiding this comment.
@samsonasik Thanks for the update, changes LGTM! Keep it up! ![]()
WyriHaximus
left a comment
There was a problem hiding this comment.
@samsonasik Much appreciate putting the time and effort in this improvement 👍
spl_object_id()is exists since php 7.2, I thinkspl_object_id()can be used when php version >= 7.2Refs:
Same implementation in reactphp/http:
https://github.com/reactphp/http/blob/c6321978bfb82de979fe4dc28eb0c08bc34937ad/src/Io/RequestHeaderParser.php#L165
Benchmark
Before call in loop took: 13.639ms
https://3v4l.org/4rUL4
After call in loop took: 4.835ms
https://3v4l.org/jKtO6