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

improvement: Only reindex workspace on onBuildTargetChanged #5737

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Oct 11, 2023

Previously, we would always reconnect to build server, which is not needed and takes longer. Instead now we only reimport and reindex the workspace.

Related to VirtusLab/scala-cli#2412

@tgodzik tgodzik force-pushed the reconnect branch 2 times, most recently from eefae0a to dd8709c Compare October 11, 2023 16:17
@tgodzik tgodzik changed the title improvement: Only reload workspace on onBuildTargetChanged improvement: Only reindex workspace on onBuildTargetChanged Oct 11, 2023

import bill.Bill

class BspBuildChangedSuite extends BaseLspSuite("bsp-build-changed") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this suite was testing exactly what I removed. I think the Scala CLI test makes much more sense.

Previously, we would always reconnect to build server, which is not needed and takes longer. Instead now we only reload and reindex the workspace.
@tgodzik tgodzik marked this pull request as ready for review October 12, 2023 12:47
buildTool,
digest,
importBuild,
case Some(BuildTool.Found(buildTool: ScalaCliBuildTool, _))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a refactor to use BuildTool.Found with checksum ready.

_ <- indexer.profiledIndexWorkspace(runDoctorCheck)
} {
focusedDocument().foreach(path => compilations.compileFile(path))
compilers.cancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

importBuild does that too, why do we need this again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... it wasn't working without it, I think we might actually need to move it as last.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, looks like we should have cancelled after build import. Moved it there.

params: b.DidChangeBuildTarget
): Unit = {
// Make sure that no compilation is running, if it is it might not get completed properly
Copy link
Contributor

Choose a reason for hiding this comment

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

How exactly?

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 am not sure, I could not reproduce it reliably. My guess is that when you send one compile first and then change using directives in another compile requests a short while later, last one will get cancelled and the first one forgotten.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And get stuck in the queue until next cancel.

Copy link
Contributor

Choose a reason for hiding this comment

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

So it's a BatchedFunction thing not a scala-cli thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but it showed up here multiple times when testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

By stuck in the queue to you mean that scala-cli won't send any response to that compile and the BatchedFunction queue is forever locked? If that's the case this is solid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it seems Scala CLI doesn't always send the respond, looks like it's a race condition, but might be hard to fix.

@tgodzik
Copy link
Contributor Author

tgodzik commented Oct 13, 2023

Let's wait to merge it until after release to be on the safe side.

@tgodzik tgodzik merged commit 505e58c into scalameta:main Oct 18, 2023
24 of 25 checks passed
@tgodzik tgodzik deleted the reconnect branch October 18, 2023 08:16
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