Improve memory consumption by using static progress callback without binding to promise#115
Merged
WyriHaximus merged 2 commits intoreactphp:2.xfrom Apr 26, 2018
Merged
Conversation
WyriHaximus
approved these changes
Apr 25, 2018
jsor
approved these changes
Apr 26, 2018
This was referenced Apr 29, 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 ideas discussed in #46. The third
$progresscallback 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.