Skip to content

Commit 3e08f26

Browse files
Stop listing all files POC
1 parent 932aa1d commit 3e08f26

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

backend/core/src/main/java/org/sonarsource/sonarlint/core/fs/FileExclusionService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public FileExclusionService(ConfigurationRepository configRepo, StorageService s
9898
}
9999

100100
public boolean computeIfExcluded(URI fileUri, SonarLintCancelMonitor cancelMonitor) {
101-
LOG.debug("Computing file exclusion for uri '{}'", fileUri);
102101
var clientFile = clientFileSystemService.getClientFile(fileUri);
103102
if (clientFile == null) {
104103
LOG.debug("Unable to find client file for uri {}", fileUri);
@@ -140,7 +139,6 @@ public boolean computeIfExcluded(URI fileUri, SonarLintCancelMonitor cancelMonit
140139
}
141140
var type = clientFile.isTest() ? InputFile.Type.TEST : InputFile.Type.MAIN;
142141
var result = !exclusionFilters.accept(serverPath.toString(), type);
143-
LOG.debug("File exclusion for uri '{}' is {}", fileUri, result);
144142
return result;
145143
}
146144

backend/core/src/main/java/org/sonarsource/sonarlint/core/sync/FindingsSynchronizationService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
package org.sonarsource.sonarlint.core.sync;
2121

2222
import java.nio.file.Path;
23+
import java.time.Instant;
2324
import java.util.LinkedList;
2425
import java.util.Set;
2526
import java.util.concurrent.CompletableFuture;
2627
import java.util.concurrent.ExecutorService;
2728
import java.util.stream.Collectors;
2829
import org.sonarsource.sonarlint.core.branch.SonarProjectBranchTrackingService;
2930
import org.sonarsource.sonarlint.core.commons.Binding;
31+
import org.sonarsource.sonarlint.core.commons.log.SonarLintLogger;
3032
import org.sonarsource.sonarlint.core.commons.progress.SonarLintCancelMonitor;
3133
import org.sonarsource.sonarlint.core.commons.util.FailSafeExecutors;
3234
import org.sonarsource.sonarlint.core.file.FilePathTranslation;
@@ -36,6 +38,7 @@
3638
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.InitializeParams;
3739

3840
public class FindingsSynchronizationService {
41+
private static final SonarLintLogger LOG = SonarLintLogger.get();
3942
private static final int FETCH_ALL_ISSUES_THRESHOLD = 10;
4043
private final ConfigurationRepository configurationRepository;
4144
private final SonarProjectBranchTrackingService branchTrackingService;
@@ -58,6 +61,7 @@ public FindingsSynchronizationService(ConfigurationRepository configurationRepos
5861
}
5962

6063
public void refreshServerFindings(String configurationScopeId, Set<Path> pathsToRefresh) {
64+
LOG.debug("Refreshing server findings for configuration scope: {}", configurationScopeId);
6165
var effectiveBindingOpt = configurationRepository.getEffectiveBinding(configurationScopeId);
6266
var activeBranchOpt = branchTrackingService.awaitEffectiveSonarProjectBranch(configurationScopeId);
6367
var translationOpt = pathTranslationService.getOrComputePathTranslation(configurationScopeId);
@@ -75,9 +79,12 @@ public void refreshServerFindings(String configurationScopeId, Set<Path> pathsTo
7579

7680
private void refreshServerIssues(SonarLintCancelMonitor cancelMonitor, Binding binding, String activeBranch,
7781
Set<Path> pathsInvolved, FilePathTranslation translation) {
82+
LOG.debug("Refreshing server issues for binding: {}, active branch: {}", binding, activeBranch);
7883
var serverFileRelativePaths = pathsInvolved.stream().map(translation::ideToServerPath).collect(Collectors.toSet());
7984
var downloadAllIssuesAtOnce = serverFileRelativePaths.size() > FETCH_ALL_ISSUES_THRESHOLD;
8085
var fetchTasks = new LinkedList<CompletableFuture<?>>();
86+
LOG.debug("Fetching issues");
87+
var now = Instant.now();
8188
if (downloadAllIssuesAtOnce) {
8289
fetchTasks.add(CompletableFuture.runAsync(() -> issueSynchronizationService.fetchProjectIssues(binding, activeBranch, cancelMonitor), issueUpdaterExecutorService));
8390
} else {
@@ -87,6 +94,7 @@ private void refreshServerIssues(SonarLintCancelMonitor cancelMonitor, Binding b
8794
.toList());
8895
}
8996
CompletableFuture.allOf(fetchTasks.toArray(new CompletableFuture[0])).join();
97+
LOG.debug("Fetching issues took {} ms", Instant.now().toEpochMilli() - now.toEpochMilli());
9098
}
9199

92100
private void refreshServerSecurityHotspots(SonarLintCancelMonitor cancelMonitor, Binding binding, String activeBranch,

backend/core/src/main/java/org/sonarsource/sonarlint/core/sync/IssueSynchronizationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ public void syncServerIssuesForProject(ServerApi serverApi, String connectionId,
6262
}
6363

6464
public void fetchProjectIssues(Binding binding, String activeBranch, SonarLintCancelMonitor cancelMonitor) {
65+
LOG.debug("Start downloading issues from SonarQube - fetchProjectIssues");
6566
sonarQubeClientManager.withActiveClient(binding.connectionId(),
6667
serverApi -> downloadServerIssuesForProject(binding.connectionId(), serverApi, binding.sonarProjectKey(), activeBranch, cancelMonitor));
6768
}
6869

6970
private void downloadServerIssuesForProject(String connectionId, ServerApi serverApi, String projectKey, String branchName, SonarLintCancelMonitor cancelMonitor) {
71+
LOG.info("[SYNC] Synchronizing issues for project '{}' on branch '{}'", projectKey, branchName);
7072
var storage = storageService.connection(connectionId);
7173
var issuesUpdater = new ServerIssueUpdater(storage, new IssueDownloader(enabledLanguagesToSync()), new TaintIssueDownloader(enabledLanguagesToSync()));
7274
issuesUpdater.update(serverApi, projectKey, branchName, enabledLanguagesToSync(), cancelMonitor);

backend/core/src/main/java/org/sonarsource/sonarlint/core/tracking/TrackingService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public void onAnalysisFailed(AnalysisFailedEvent event) {
172172

173173
@EventListener
174174
public void onAnalysisFinished(AnalysisFinishedEvent event) {
175+
LOG.debug("Analysis finished: {}", event);
175176
var analysisId = event.getAnalysisId();
176177
var matchingSession = matchingSessionByAnalysisId.remove(analysisId);
177178
if (matchingSession == null) {

backend/server-connection/src/main/java/org/sonarsource/sonarlint/core/serverconnection/ServerIssueUpdater.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.sonarsource.sonarlint.core.serverconnection;
2121

2222
import java.nio.file.Path;
23+
import java.time.Instant;
2324
import java.util.ArrayList;
2425
import java.util.List;
2526
import java.util.Set;
@@ -29,6 +30,7 @@
2930
import org.sonarsource.sonarlint.core.serverapi.ServerApi;
3031
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerIssue;
3132
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerTaintIssue;
33+
import org.sonarsource.sonarlint.core.serverconnection.storage.ProjectServerIssueStore;
3234
import org.sonarsource.sonarlint.core.serverconnection.storage.UpdateSummary;
3335

3436
import static java.util.stream.Collectors.toSet;
@@ -50,8 +52,16 @@ public ServerIssueUpdater(ConnectionStorage storage, IssueDownloader issueDownlo
5052

5153
public void update(ServerApi serverApi, String projectKey, String branchName, Set<SonarLanguage> enabledLanguages, SonarLintCancelMonitor cancelMonitor) {
5254
if (serverApi.isSonarCloud()) {
55+
LOG.debug("Start downloading issues from SonarQube Cloud");
56+
var start = Instant.now();
5357
var issues = issueDownloader.downloadFromBatch(serverApi, projectKey, branchName, cancelMonitor);
54-
storage.project(projectKey).findings().replaceAllIssuesOfBranch(branchName, issues, enabledLanguages);
58+
var finishedDownload = Instant.now();
59+
LOG.debug("Finished downloading {} issues from SonarQube Cloud in {} ms", issues.size(), finishedDownload.toEpochMilli() - start.toEpochMilli());
60+
var issueStore = storage.project(projectKey).findings();
61+
LOG.debug("Issue store type: {}", issueStore.getClass().getSimpleName());
62+
issueStore.replaceAllIssuesOfBranch(branchName, issues, enabledLanguages);
63+
var finishedWritingToStorage = Instant.now();
64+
LOG.debug("Finished updating {} issues in storage in {} ms", issues.size(), finishedWritingToStorage.toEpochMilli() - finishedDownload.toEpochMilli());
5565
} else {
5666
sync(serverApi, projectKey, branchName, issueDownloader.getEnabledLanguages(), cancelMonitor);
5767
}
@@ -61,10 +71,13 @@ public void sync(ServerApi serverApi, String projectKey, String branchName, Set<
6171
var lastSync = storage.project(projectKey).findings().getLastIssueSyncTimestamp(branchName);
6272

6373
lastSync = computeLastSync(enabledLanguages, lastSync, storage.project(projectKey).findings().getLastIssueEnabledLanguages(branchName));
64-
74+
Instant start = Instant.now();
6575
var result = issueDownloader.downloadFromPull(serverApi, projectKey, branchName, lastSync, cancelMonitor);
76+
var downloadTime = Instant.now();
77+
LOG.debug("Downloaded {} issues took {}", result.getChangedIssues().size(), downloadTime.toEpochMilli() - start.toEpochMilli());
6678
storage.project(projectKey).findings().mergeIssues(branchName, result.getChangedIssues(), result.getClosedIssueKeys(),
6779
result.getQueryTimestamp(), enabledLanguages);
80+
LOG.debug("Finished updating {} issues in storage in {} ms", result.getChangedIssues().size(), Instant.now().toEpochMilli() - downloadTime.toEpochMilli());
6881
}
6982

7083
public UpdateSummary<ServerTaintIssue> syncTaints(ServerApi serverApi, String projectKey, String branchName, Set<SonarLanguage> enabledLanguages,

backend/server-connection/src/main/java/org/sonarsource/sonarlint/core/serverconnection/storage/ServerFindingRepository.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.sonarsource.sonarlint.core.serverconnection.storage;
2121

2222
import java.nio.file.Path;
23+
import java.time.Duration;
2324
import java.time.Instant;
2425
import java.time.LocalDateTime;
2526
import java.time.ZoneId;
@@ -36,6 +37,7 @@
3637
import org.jooq.TableField;
3738
import org.sonarsource.sonarlint.core.commons.HotspotReviewStatus;
3839
import org.sonarsource.sonarlint.core.commons.api.SonarLanguage;
40+
import org.sonarsource.sonarlint.core.commons.log.SonarLintLogger;
3941
import org.sonarsource.sonarlint.core.commons.storage.SonarLintDatabase;
4042
import org.sonarsource.sonarlint.core.commons.storage.model.Tables;
4143
import org.sonarsource.sonarlint.core.commons.storage.model.tables.records.ServerBranchesRecord;
@@ -50,7 +52,7 @@
5052
import static org.sonarsource.sonarlint.core.commons.storage.model.Tables.SERVER_FINDINGS;
5153

5254
public class ServerFindingRepository implements ProjectServerIssueStore {
53-
55+
private static final SonarLintLogger LOG = SonarLintLogger.get();
5456
private final EntityMapper mapper = new EntityMapper();
5557
private final SonarLintDatabase database;
5658
private final String connectionId;
@@ -574,9 +576,12 @@ private void batchMergeHotspots(String branchName, String connectionId, String s
574576
}
575577

576578
private void batchMergeIssues(String branchName, String connectionId, String sonarProjectKey, Configuration trx, Collection<ServerIssue<?>> issues) {
579+
LOG.debug("Batch merging {} issues for branch '{}' and project '{}'", issues.size(), branchName, sonarProjectKey);
580+
var start = Instant.now();
577581
trx.dsl().batchMerge(issues.stream()
578582
.map(issue -> mapper.serverIssueToRecord(issue, branchName, connectionId, sonarProjectKey)).toList())
579583
.execute();
584+
LOG.debug("Batch merge completed in {} ms", Duration.between(start, Instant.now()).toMillis());
580585
}
581586

582587
private void batchMergeTaints(String branchName, String connectionId, String sonarProjectKey, Configuration trx, Collection<ServerTaintIssue> taints) {

backend/server-connection/src/main/java/org/sonarsource/sonarlint/core/serverconnection/storage/XodusServerIssueStore.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ public boolean wasEverUpdated() {
484484

485485
@Override
486486
public void replaceAllIssuesOfBranch(String branchName, List<ServerIssue<?>> issues, Set<SonarLanguage> enabledLanguages) {
487+
LOG.debug("Replacing all issues of branch {} with {} issues", branchName, issues.size());
488+
var start = Instant.now();
487489
var issuesByFile = issues.stream().collect(Collectors.groupingBy(ServerIssue::getFilePath));
488490
timed(wroteMessage(issues.size(), ISSUES), () -> entityStore.executeInTransaction(txn -> {
489491
var branch = getOrCreateBranch(branchName, txn);
@@ -501,6 +503,7 @@ public void replaceAllIssuesOfBranch(String branchName, List<ServerIssue<?>> iss
501503
txn.flush();
502504
});
503505
}));
506+
LOG.debug("Finished replacing all issues of branch {} in {} ms", branchName, Duration.between(start, Instant.now()).toMillis());
504507
}
505508

506509
@Override

0 commit comments

Comments
 (0)