diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-05-04 16:30:03 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-05-12 11:18:19 +0200 |
commit | 3b0bc018071a7ffb61e929927594871341261314 (patch) | |
tree | ff91aa576ba4089e6d177203b0d9a9913a9cbd8a | |
parent | 4b655d90490eb074d2e6192709146cb2744c0010 (diff) | |
download | sonarqube-3b0bc018071a7ffb61e929927594871341261314.tar.gz sonarqube-3b0bc018071a7ffb61e929927594871341261314.zip |
SONAR-6315 index changes per quality profile to avoid OOM
because indexing only at the end of MassRegisterQualityProfiles means holding every changes for every QP for every organization in memory and this can be a lot
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/qualityprofile/MassRegisterQualityProfiles.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/MassRegisterQualityProfiles.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/MassRegisterQualityProfiles.java index 6cdd4a91a3b..7d933634e1f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/MassRegisterQualityProfiles.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/MassRegisterQualityProfiles.java @@ -77,10 +77,10 @@ public class MassRegisterQualityProfiles { try (DbSession session = dbClient.openSession(false); DbSession batchSession = dbClient.openSession(true)) { + // memory optimization: use a single array list for everything to avoid reallocating and increasing new array for each quality profiles List<ActiveRuleChange> changes = new ArrayList<>(); definedQProfileRepository.getQProfilesByLanguage() .forEach((key, value) -> registerPerLanguage(session, batchSession, value, changes)); - activeRuleIndexer.index(changes); profiler.stopDebug(); } } @@ -97,6 +97,10 @@ public class MassRegisterQualityProfiles { while (!(organizationDtos = getOrganizationsWithoutQP(session, qualityProfile)).isEmpty()) { organizationDtos.forEach(organization -> registerPerQualityProfileAndOrganization(session, batchSession, qualityProfile, organization, changes, profiler)); } + profiler.startDebug("Indexing for profile " + qualityProfile.getQProfileName()); + activeRuleIndexer.index(changes); + changes.clear(); + profiler.stopDebug(); } private List<OrganizationDto> getOrganizationsWithoutQP(DbSession session, DefinedQProfile qualityProfile) { |