perf: skip reloadWorkspace() when compile tasks are all UP-TO-DATE#222
Merged
wenytang-ms merged 1 commit intodevelopfrom Apr 3, 2026
Merged
perf: skip reloadWorkspace() when compile tasks are all UP-TO-DATE#222wenytang-ms merged 1 commit intodevelopfrom
wenytang-ms merged 1 commit intodevelopfrom
Conversation
ac75ac6 to
01b5d95
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Improves compile-time performance by avoiding expensive workspace model reloads after buildTargetCompile when Gradle reports that all relevant tasks were skipped or UP-TO-DATE.
Changes:
- Track whether any compile-related Gradle task performed real work via
CompileProgressReporter.hasExecutedWork(). - Conditionally schedule
reloadWorkspace()only when work was executed. - Add informational logging around the reload decision.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java | Only schedules reloadWorkspace() after compile when tasks executed work; adds logging. |
| server/src/main/java/com/microsoft/java/bs/core/internal/reporter/CompileProgressReporter.java | Adds a flag to detect non-UP-TO-DATE/non-skipped task outcomes and exposes it to callers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
server/src/main/java/com/microsoft/java/bs/core/internal/reporter/CompileProgressReporter.java
Show resolved
Hide resolved
server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/microsoft/java/bs/core/internal/services/BuildTargetService.java
Show resolved
Hide resolved
After every buildTargetCompile, the server unconditionally calls reloadWorkspace() to detect source root changes from code generation frameworks. However, reloadWorkspace() is expensive — it does a full Gradle Tooling API model query (getGradleSourceSets) which takes 1-2s. When all compile tasks are UP-TO-DATE (no work done), the project model cannot have changed, so reloadWorkspace() is unnecessary. This commonly happens during auto-build cycles where Eclipse triggers repeated incremental builds with no code changes. Track whether any compile task performed actual work via the existing TaskSuccessResult.isUpToDate() / TaskSkippedResult checks in CompileProgressReporter. Skip reloadWorkspace() when all tasks were no-op, saving ~1-2s per redundant auto-build cycle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
01b5d95 to
5ff123c
Compare
chagong
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After every
buildTargetCompile, the server unconditionally callsreloadWorkspace()to detect source root changes from code generation frameworks (e.g., Protocol Buffers). However,reloadWorkspace()is expensive — it does a full Gradle Tooling API model query (getGradleSourceSets()) which takes ~1-2s per call.This is particularly wasteful during Eclipse auto-build cycles. After the initial compile, subsequent auto-builds produce all UP-TO-DATE tasks (no code changed), but
reloadWorkspace()still runs every time:This adds ~4-8s of unnecessary Gradle Tooling API overhead after each test run or debug launch.
Root Cause
BuildTargetService.compile()always schedulesreloadWorkspace()after compilation, regardless of whether any work was actually done:The information about whether tasks were UP-TO-DATE is already available in
CompileProgressReporter.statusChanged()viaTaskSuccessResult.isUpToDate()andTaskSkippedResult, butcompile()doesn't use it.Fix
hasExecutedWorkflag toCompileProgressReporterthat tracks whether any task performed actual work (not skipped, not UP-TO-DATE).compile(), only callreloadWorkspace()whenreporter.hasExecutedWork()is true.When all tasks are UP-TO-DATE, no new files were produced, so the project model cannot have changed —
reloadWorkspace()is safely skipped.Risk Assessment
hasExecutedWorkwill be true and reload will happen normally.Performance Impact
For a workspace with 5 Gradle subprojects after running a test:
reloadWorkspace()callsRelated: microsoft/vscode-gradle#1794 (fixed the infinite rebuild loop; this PR reduces remaining convergence overhead)