fix(project): reduce memory consumption by using optimized CouchDB view#3985
Draft
bibhuti230185 wants to merge 1 commit intoeclipse-sw360:mainfrom
Draft
fix(project): reduce memory consumption by using optimized CouchDB view#3985bibhuti230185 wants to merge 1 commit intoeclipse-sw360:mainfrom
bibhuti230185 wants to merge 1 commit intoeclipse-sw360:mainfrom
Conversation
…ew for project cache Signed-off-by: Bibhuti Bhusan Dash <bibhuti230185@gmail.com>
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.
Summary
This PR optimizes memory consumption in the project clearing cache by replacing
repository.getAll()with a dedicated CouchDB view that fetches only cache-relevant fields.Problem
The
cachedAllProjectsIdMapinProjectDatabaseHandlerwas consuming ~83% of heap memory due to caching all project fields (including heavy fields like descriptions, external IDs, security assessments, etc.) for every project in the system.Solution
forClearingCacheinProjectRepositorythat emits only the 12 fields required for clearing state cache operationsgetRefreshedAllProjectsIdMap()to use the optimized view instead ofrepository.getAll()Fields included in the optimized view:
_id- Project identifierlinkedProjects- Project hierarchy relationshipsreleaseIdToUsage- Release dependenciescreatedBy,projectResponsible,leadArchitect- User permissionsmoderators,contributors- Permission groupsbusinessUnit- Access controlvisbility- Visibility settingsclearingState- Clearing workflow stateattachments- Attachment metadataChanges Made
forClearingCacheview with map/reduce functionsIssue: N/A (Performance optimization identified through heap dump analysis)
Suggest Reviewer
@GMishx - This change affects the project clearing cache mechanism
How To Test?
Unit Tests
mvn test -pl backend/common -Dtest=ProjectRepositoryTestAll 4 new test cases verify:
Integration Testing
Memory Profiling (Recommended)
ProjectDatabaseHandler.cachedAllProjectsIdMapmemory usageChecklist
Must:
Additional Notes