microsoft / build-server-for-gradle

An implementation of the Build Server Protocol for Gradle
MIT License
45 stars 7 forks source link

sidhaarth:bsp-cancellation : BSP Gradle Cancellation #148

Closed Sidhaarthsr closed 1 week ago

jdneo commented 3 weeks ago

Hi @Sidhaarthsr,

There are something that you can make further investigation:

About the CancelChecker

So, as you can see, In GradleBuildServer.java a lot of request handling method has already passed an argument cc, which is the cancel checker. Ideally, when the client sends a cancel request to the server, we should be able to be notified that via the cancel checker. This capability should be provided by the underlying lsp4j.jsonrpc library. I haven't tested it yet, so this is something that you can take a look maybe. If's it's working as expected, than we can let the cancel checker as another parameter for all those request handling method. And check it when necessary. (I'm not sure that check it regularly in another thread is a good idea, do you have any reference for this approach?)

About cancel the task executed in Gradle Daemon

When we use gradle tooling api to let Gradle daemon do some task for us, Gradle TAPI also supports cancellation.

Please keep in mind that the Gradle build server and Gradle Daemon are running in two different process. If we just simply cancel the request at Gradle build server side, but not notify the cancellation to the Gradle Daemon. The computation resources are still wasted.

So we need to figure out a way to establish kind of connection between:

jdneo commented 1 week ago

@Sidhaarthsr Any issue you've met?

Sidhaarthsr commented 1 week ago

@jdneo The branch got deleted and the PR was closed due to a branch rename. PR #157 is a continuation of this.