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

Improve memory consumption by using static progress callback without binding to promise #115

Merged
merged 2 commits into from
Apr 26, 2018

Conversation

clue
Copy link
Member

@clue clue commented Apr 25, 2018

This builds on top of the ideas discussed in #46. The third $progress callback passed to the resolver is deprecated as of #112 and as such should not be used for most applications.

This PR ensures that this callback never causes a cyclic garbage reference as discussed in #46. This builds on top of the work done in #113. If you do not access any arguments, this PR has no effect (also no performance or memory penalty).

If you do access any of the arguments, you no longer have to care about this method memory wise, as it will no longer cause a cyclic garbage reference. A similar patch will follow for the other two callbacks, but I figured it's worth discussing this concept on its own first.

Invoking the benchmarking example from #113 shows that this has no little effect on performance (1M invocations that do no use arguments show no performance improvements, 1M invocations that do use arguments show a ~4% performance degradation).

This PR actually includes a test that shows how garbage memory references can be avoided in PHP 7+ and how this method does no longer cause any such references on its own.

@clue clue added this to the v2.6.0 milestone Apr 25, 2018
@WyriHaximus WyriHaximus merged commit da16050 into reactphp:2.x Apr 26, 2018
@clue clue deleted the static-progress branch April 26, 2018 11:10
jsor added a commit to jsor-labs/pact that referenced this pull request May 16, 2018
This incorporates the work done by @clue in the following PR's for reactphp/promise:

* reactphp/promise#115
* reactphp/promise#116
* reactphp/promise#117
* reactphp/promise#118
* reactphp/promise#119

Co-authored-by: Christian Lück <christian@lueck.tv>
jsor added a commit to jsor-labs/pact that referenced this pull request May 16, 2018
This incorporates the work done by @clue in the following PR's for reactphp/promise:

* reactphp/promise#113
* reactphp/promise#115
* reactphp/promise#116
* reactphp/promise#117
* reactphp/promise#118
* reactphp/promise#119

Co-authored-by: Christian Lück <christian@lueck.tv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants