Skip to content

Cache context base base in quote driver #4643

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 3 commits into from
Jun 27, 2018

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Jun 10, 2018

This enables caching the compiler used of call Expr.run.

import dotty.tools.dotc.tastyreflect.TastyImpl

class QuoteDriver extends Driver {
import tpd._

def run[T](expr: Expr[T], settings: Settings[Run]): T = {
private[this] val contextBase: ContextBase = new ContextBase
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is thread-safe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not and not intended to be. Each thread should generate its own toolbox. I will add documentation and thick how to check that they do not use the same compiler in two threads.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to make it thread-safe by synchronization instead. If someone wants parallelism they should create several instances of the Toolbox

Copy link
Member

Choose a reason for hiding this comment

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

Decided to make it thread-safe by synchronization instead.

I don't see any synchronization logic in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must have lost that commit in one of the reading. I will add it again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Searching for synchronized still finds nothing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is in #4746

@nicolasstucki
Copy link
Contributor Author

Rebased

nicolasstucki added a commit to dotty-staging/dotty that referenced this pull request Jun 19, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this pull request Jun 19, 2018
* Cache the driver itself
* Cache context base in the driver
* Addapt toolbox settings
* Use cached toolbox in tests
@nicolasstucki
Copy link
Contributor Author

Rebased and reenabled test

@biboudis
Copy link
Contributor

Also had a look. Seems good.

@allanrenucci allanrenucci requested a review from biboudis June 26, 2018 13:16
@nicolasstucki nicolasstucki merged commit 38d07d9 into scala:master Jun 27, 2018
@allanrenucci allanrenucci deleted the cache-tasty-driver branch June 27, 2018 08:32
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.

4 participants