Improve memory consumption by using static resolve and reject callback without binding to promise#116
Merged
jsor merged 1 commit intoreactphp:2.xfrom May 3, 2018
Merged
Conversation
WyriHaximus
approved these changes
Apr 29, 2018
jsor
approved these changes
May 3, 2018
This was referenced May 4, 2018
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]>
This was referenced Jun 9, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This builds on top of the implementation approach in #115 and the ideas discussed in #46.
The
$resolveand$rejectcallbacks 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
$progresscallback 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).