Skip to content

Don’t create an EventLoopFuture chain #4

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

Merged
merged 2 commits into from
Mar 6, 2020

Conversation

fabianfett
Copy link
Member

Currently we build up an EventLoopFuture chain. This pr fixes this. Its performance (speed) though is a little slower than before. But I think not running into memory limits at this point outweighs the performance considerations.

@fabianfett fabianfett force-pushed the ff-dont-leak-eventloopfutures branch 2 times, most recently from c0839ef to f24a9ce Compare March 5, 2020 14:20
@fabianfett
Copy link
Member Author

Verified with instruments that memory is not increasing anymore.

@fabianfett
Copy link
Member Author

If we add an @inline(__always) to the private func run(runner: LambdaRunner) the cold start time is at least as good as master if not better. I'd assume this happens since LambdaRunner (a struct) is not copied when it is inlined and therefore the it's properties don't have to be copied/refcounted. I don't know if this explanation is reasonable.

@fabianfett fabianfett force-pushed the ff-dont-leak-eventloopfutures branch from f24a9ce to 0bd5415 Compare March 5, 2020 17:32
@fabianfett fabianfett requested a review from tomerd March 5, 2020 21:41
Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome find, some little comments

@fabianfett fabianfett force-pushed the ff-dont-leak-eventloopfutures branch from 0bd5415 to 8b03533 Compare March 6, 2020 07:26
@fabianfett fabianfett force-pushed the ff-dont-leak-eventloopfutures branch from 8b03533 to 70e1647 Compare March 6, 2020 07:27
@fabianfett fabianfett requested a review from tomerd March 6, 2020 07:36
@@ -89,7 +89,7 @@ class LambdaTest: XCTestCase {
}
let result = try future.wait()
XCTAssertGreaterThan(result, 0, "should have stopped before any request made")
XCTAssertLessThan(result, maxTimes, "should have stopped before \(maxTimes)")
XCTAssertLessThanOrEqual(result, maxTimes, "should have stopped at \(maxTimes)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to change maxTimes to some larger number (1000) instead otherwise we loose the test value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix, the XCTAssertLessThan should stay so we are testing we stopped before reaching maxTimes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Sure that makes tons of sense.

@fabianfett fabianfett force-pushed the ff-dont-leak-eventloopfutures branch 2 times, most recently from 3fa503f to 33c7288 Compare March 6, 2020 20:08
@fabianfett fabianfett force-pushed the ff-dont-leak-eventloopfutures branch from 33c7288 to 8da62ce Compare March 6, 2020 20:10
@tomerd tomerd merged commit 01ef788 into master Mar 6, 2020
tomerd pushed a commit that referenced this pull request Mar 6, 2020
motivation: prevent memory bloat

changes:
* recurse instead of event loop chain
* fix flaky test
tomerd pushed a commit that referenced this pull request Mar 7, 2020
motivation: prevent memory bloat

changes: 
* recurse instead of event loop chain
* fix flaky test
tomerd pushed a commit that referenced this pull request Mar 7, 2020
motivation: prevent memory bloat

changes: 
* recurse instead of event loop chain
* fix flaky test
tomerd pushed a commit that referenced this pull request Mar 7, 2020
motivation: prevent memory bloat

changes: 
* recurse instead of event loop chain
* fix flaky test
tomerd pushed a commit that referenced this pull request Mar 7, 2020
motivation: prevent memory bloat

changes: 
* recurse instead of event loop chain
* fix flaky test
tomerd pushed a commit that referenced this pull request Mar 7, 2020
motivation: prevent memory bloat

changes: 
* recurse instead of event loop chain
* fix flaky test
@tomerd tomerd deleted the ff-dont-leak-eventloopfutures branch March 7, 2020 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants