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

feat(mutants): Prevent memory leak when transpiling mutants #1376

Merged
merged 5 commits into from
Feb 12, 2019

Conversation

nicojs
Copy link
Member

@nicojs nicojs commented Feb 11, 2019

Instead of transpiling all mutants at once, this PR makes it so that at
most 100 mutants are transpiled at any one time.
After that, it waits for the mutants to be tested before transpiling any more of them.

Fixes #920

Instead of transpiling all mutants at once, this PR makes it so that at
most 100 mutants are transpiled at any one time.
After that, it waits for the mutants to be tested before transpiling any more of them.

Fixes #920
@ghost ghost assigned nicojs Feb 11, 2019
@ghost ghost added the 🔎 Needs review label Feb 11, 2019
@nicojs nicojs requested a review from simondel February 11, 2019 14:17
Copy link
Member

@simondel simondel left a comment

Choose a reason for hiding this comment

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

Could you look at my remarks?

this.workingDirectory = TempFolder.instance().createRandomFolder('sandbox');
this.log.debug('Creating a sandbox for files in %s', this.workingDirectory);
this.files = files.slice(); // Create a copy
Copy link
Member

Choose a reason for hiding this comment

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

Why do we no longer have to make a slice?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's no longer needed. We no longer mutate the original (it is a ReadonlyArray)

const backlogItem = this.backlog.shift();
if (backlogItem) {
if (this.isDisposed) {
backlogItem.task.resolve({ status: RunStatus.Timeout, tests: [] });
Copy link
Member

Choose a reason for hiding this comment

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

So if the entire pool is disposed you resolve the last backlog item as a Timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

All remaining backlog items are timedout. We need another way of dealing with this, the problem is I don't know exactly how. It is non-trivial functionality.

Note: this shouldn't happen. We only dispose the sandbox pool once all results are in. We'll be able to remove this code once we make typed-inject responsible to dispose our stuff.

tap(this.reportAll)
).toPromise();

// TODO: Let typed inject dispose of sandbox pool
Copy link
Member

Choose a reason for hiding this comment

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

Is this TODO still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is. Once all disposable instances are created with typed-inject we can use it to dispose all our stuff. As for now, we cannot do that, so that's what this hack is for.

NOTE: this functionality didn't change. Disposing was always done at this point.

if (recycleObserver) {
recycleObserver.complete();
}
const early = this.earlyResult(transpiledMutant);
Copy link
Member

Choose a reason for hiding this comment

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

Could you rename this to const earlyResult = this.getEarlyResult(transpiledMutant);?

Copy link
Member Author

@nicojs nicojs Feb 11, 2019

Choose a reason for hiding this comment

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

I don't like the name getEarlyResult (Java has pretty much ruined getXxx for me 🙈) . I'll change it to retrieveEarlyResult.

*/
public dispose() {
this.concurrencyTicket$.complete();
// TODO: Let typed-inject dispose this one
Copy link
Member

Choose a reason for hiding this comment

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

Is this TODO still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is. Once all disposable instances are created with typed-inject we can use it to dispose all our stuff. As for now, we cannot do that, so that's what this hack is for.

@nicojs
Copy link
Member Author

nicojs commented Feb 11, 2019

I've commented on / fixed all remarks. Thanks for the review

Copy link
Member

@simondel simondel left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@nicojs nicojs merged commit 45c2852 into master Feb 12, 2019
@ghost ghost removed the 🔎 Needs review label Feb 12, 2019
@nicojs nicojs deleted the 920-transpile-mutants-backlog branch February 12, 2019 11:27
@nicojs nicojs mentioned this pull request Feb 12, 2019
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