Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented Jul 20, 2017

While shrinking we have to allocate containers for the reduced domains
for some of the candidates, it's currently done using permanent arena
of the ASTContext allocator. This patch changes candidate solver to
use arena associated with the parent constraint system, which significantly
limits lifetime of domain containers.

@xedin xedin requested a review from rudkx July 20, 2017 09:21
@xedin xedin force-pushed the shrink-memory-leak branch from 2a10240 to 48f37ab Compare July 20, 2017 10:07
@swiftlang swiftlang deleted a comment from swift-ci Jul 20, 2017
@swiftlang swiftlang deleted a comment from swift-ci Jul 20, 2017
@xedin xedin force-pushed the shrink-memory-leak branch 2 times, most recently from 8f4878b to a7df2b5 Compare July 21, 2017 00:13
@xedin
Copy link
Contributor Author

xedin commented Jul 21, 2017

/cc @jrose-apple mostly changes in the ASTContext

@xedin
Copy link
Contributor Author

xedin commented Jul 21, 2017

@swift-ci please smoke test

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would just skip the whole change for ASTContext and use the BumpPtrAllocator directly. You should be able to do this:

MutableArrayRef<ValueDecl *> decls(Allocator.Allocate<ValueDecl *>(choices.size()),
                                   choices.size());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Thanks for the suggestion!

@xedin xedin force-pushed the shrink-memory-leak branch from a7df2b5 to 499be58 Compare July 21, 2017 03:29
@xedin
Copy link
Contributor Author

xedin commented Jul 21, 2017

@swift-ci please clean smoke test

@xedin xedin force-pushed the shrink-memory-leak branch from 499be58 to 0eeab31 Compare August 13, 2017 04:16
@xedin
Copy link
Contributor Author

xedin commented Aug 13, 2017

@swift-ci please smoke test

Copy link
Contributor

Choose a reason for hiding this comment

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

What keeps this from outliving the constraint system?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If expression is correct there is not going to be any OSR expressions in it after ExprRewriter because all of the ambiguities have been resolved. But I think the right fix is to allocate to constraint system arena all of the intermediate arrays that shrink creates but at the end of the shrink phrase re-allocate all of the final arrays to perm arena to make sure that diagnostics are ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, that first part isn't good enough for code completion and indexing, where the expression may not be complete or correct.

…ystem arena

While shrinking we have to allocate containers for the reduced domains
for some of the candidates, it's currently done using permanent arena
of the `ASTContext` allocator. This patch changes candidate solver to
use arena associated with the parent constraint system, which significantly
limits lifetime of domain containers.
@xedin xedin force-pushed the shrink-memory-leak branch from 0eeab31 to 7a1bae8 Compare August 14, 2017 19:54
@xedin
Copy link
Contributor Author

xedin commented Aug 14, 2017

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Aug 14, 2017

@rudkx all of the intermediate arrays used for decls are going to be allocated temporarily while main constraint system is alive but the final versions are going to be still permanent because we might need to keep OSR longer for diagnostics.

Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

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

LGTM!

@xedin xedin merged commit fd253da into swiftlang:master Aug 14, 2017
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.

3 participants