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

refactor: don't send task start/end for no-op compilations #2274

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

ckipp01
Copy link
Member

@ckipp01 ckipp01 commented Feb 16, 2024

This might be a bit opinionated and I'm not 100% sure on the reason this was done in the first place, but this changes the current behavior around reporting start and end compilations for no-ops. This still retains the compile report if it was a no-op and also still checks the diagnostics and reports them, but skips the task start/end.

Originally this was added in a commit without any context... but there was a comment that said:

// When no-op, we keep reporting the start and the end of compilation for consistency

However, I'm not really sure that consistency matters here. In reality this ends up creating a bunch of noise on the client side, especially when these tasks turn into LSP progress notifications that aren't useful for the user to see. You can see more context about this change in the issue reported here and also the discussion found
here. It also seems that in some projects like scala-cli these are even ignored.

This might be a bit opinionated and I'm not 100% sure on the reason this
was done in the first place, but this changes the current behavior
around reporting start and end compilations for no-ops. This still
retains the compile report if it was a no-op and also still checks the
diagnostics and reports them, but skips the task start/end.

Originally this was added in a commit without any context... but there
was a comment that said:

> // When no-op, we keep reporting the start and the end of compilation for consistency

However, I'm not really sure that consistency matters here. In reality
this ends up creating a bunch of noise on the client side, especially
when these tasks turn into LSP progress notifications that aren't useful
for the user to see. You can see more context about this change in the
issue reported [here](scalameta/metals#6099)
and also the discussion found
[here](build-server-protocol/build-server-protocol#654).
It also seems that in some projects like scala-cli these are even [ignored](https://github.com/VirtusLab/scala-cli/blob/6b7a10007e4eefde717079255e0df38c027f788b/modules/build/src/main/scala/scala/build/ConsoleBloopBuildClient.scala#L109).
Copy link
Contributor

@tgodzik tgodzik 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, just two questions, but nothing blocking. Thanks for looking into this!

| -> Msg: Compiled 'a'
| -> Data kind: compile-report
""".stripMargin
""".stripMargin // no-op so it only gives the compile-report
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, compile report is in the task finish, so we only get the compile response, no? But that should be fine as nothing really changes

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, yea sorry that's my mistake. I was switching up the names of the compile response and compile report. You're correct, it's only the compile response that is now returned.

@@ -603,7 +590,7 @@ class BspCompileSpec(
assertSameExternalClassesDirs(fourthCompiledState, compiledState, projects)
assertNoDiff(
fourthCompiledState.lastDiagnostics(`A`),
"""#4: task start 4
"""#4: task start 3
Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea why these changed if there was no noop compilation beforehand?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea exactly, since there was a no-op in there, there is no one less task which lowers the count.

@adpi2
Copy link
Member

adpi2 commented Feb 19, 2024

Ahh, yea sorry that's my mistake. I was switching up the names of the compile response and compile report. You're correct, it's only the compile response that is now returned.

So the compile response is sent but not the compile report. Yet there is no noOp field in the compile response, so how does the client know it is a no-op compilation? Does it even need to know? All of this should be clearly documented in BSP if we want some sort of consistency across all build servers.

Also it seems it would be harder to implement the same behavior in sbt, because we don't know beforehand if a compilation is going to be a no-op.

@ckipp01
Copy link
Member Author

ckipp01 commented Feb 19, 2024

So the compile response is sent but not the compile report. Yet there is no noOp field in the compile response, so how does the client know it is a no-op compilation? Does it even need to know?

That's a good question. I guess it'd be ideal to still know in the actual response in case clients handle them in specific ways, but then again it's the task notifications that end up being noisy, not the compile response, so maybe it doesn't matter that much.

All of this should be clearly documented in BSP if we want some sort of consistency across all build servers.

Agreed.

Copy link
Member

@adpi2 adpi2 left a comment

Choose a reason for hiding this comment

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

I am okay to merge this but I also recommend to add the noOp field in the CompileResult

@ckipp01
Copy link
Member Author

ckipp01 commented Feb 19, 2024

I am okay to merge this but I also recommend to add the noOp field in the CompileResult

Sounds good. When I get a bit of time I'll outline all of this in the discussion I started in the BSP repo and re-phrase my original question and change the discussion to just aligning on how no-ops are meant to be handled.

@ckipp01 ckipp01 merged commit 3eeab02 into scalacenter:main Feb 19, 2024
16 of 17 checks passed
@ckipp01 ckipp01 deleted the no-op branch February 19, 2024 09:46
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