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 resolve and reject callback without binding to promise #116

Merged
merged 1 commit into from
May 3, 2018

Conversation

clue
Copy link
Member

@clue clue commented Apr 29, 2018

This builds on top of the implementation approach in #115 and the ideas discussed in #46.

The $resolve and $reject callbacks passed to the resolver and cancellation functions of each promise now no longer cause a cyclic garbage reference in any exception trace 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 these functions memory wise, as they will no longer cause a cyclic garbage reference. A similar patch has been introduced for the $progress callback in #115 and this means this now consistently applies to all callbacks.

Invoking the benchmarking example from #113 shows that this has 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 are no longer an issue in any supported PHP version and how these functions no longer cause any such references on their own (unlike the previous test in #115 this means that this requires no effort on the consumer side anymore).

@clue clue added this to the v2.6.0 milestone Apr 29, 2018
@WyriHaximus WyriHaximus requested review from jsor and WyriHaximus April 29, 2018 17:43
@jsor jsor merged commit 24cd9e8 into reactphp:2.x May 3, 2018
@clue clue deleted the static-settle branch May 3, 2018 19:03
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 <[email protected]>
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 <[email protected]>
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.

3 participants