Issue Summary
The Sprint field drawdown suggestion can be CPU hungry and take a long time to calculate due to the following hotspot
https://stash.atlassian.com/projects/jswserver/repos/jira-agile/browse/greenhopper/src/main/java/com/atlassian/greenhopper/web/rapid/sprint/SprintResource.java?at=230fa87c55fdb18d803279df30b333fa58086f4f#99
Set<Sprint> allMatches = check(sprintHelper.findSprintPickerAllMatches(user, suggestions, searchQuery, maxResults, excludeCompleted));

The Sprint field suggestion is calculated based on users' last 5 visited Sprint. If a user has not to visit a minimum of 5 Sprint, the suggestion will be calculated by retrieving ALL SPRINT available to the user and perform some calculation to return number issues associated with each Sprint.
In large instances, with 3M issues and 52K Sprints, this operation alone can take 2 minutes to complete and consume significant CPU.
In the thread dump, you will see the following thread exist in multiple threads (ie. longer than 60-180s)
url:/rest/greenhopper/1.0/sprint/picker?query username:vkharisma
java.util.TreeMap.getEntry(TreeMap.java:359)
java.util.TreeMap.get(TreeMap.java:278)
org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsReader.terms(PerFieldPostingsFormat.java:315)
org.apache.lucene.index.CodecReader.terms(CodecReader.java:106)
org.apache.lucene.search.TermQuery$TermWeight.getTermsEnum(TermQuery.java:122)
org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:90)
org.apache.lucene.search.Weight.scorerSupplier(Weight.java:113)
org.apache.lucene.search.LRUQueryCache$CachingWrapperWeight.scorerSupplier(LRUQueryCache.java:720)
org.apache.lucene.search.BooleanWeight.scorerSupplier(BooleanWeight.java:329)
org.apache.lucene.search.BooleanWeight.scorer(BooleanWeight.java:295)
org.apache.lucene.search.Weight.bulkScorer(Weight.java:147)
org.apache.lucene.search.BooleanWeight.bulkScorer(BooleanWeight.java:289)
org.apache.lucene.search.LRUQueryCache$CachingWrapperWeight.bulkScorer(LRUQueryCache.java:795)
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:657)
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:462)
com.atlassian.jira.index.DelegateSearcher.search(DelegateSearcher.java:169)
com.atlassian.jira.index.DelegateSearcher.search(DelegateSearcher.java:169)
com.atlassian.jira.index.UnmanagedIndexSearcher.search(UnmanagedIndexSearcher.java:9)
com.atlassian.jira.index.DelegateSearcher.search(DelegateSearcher.java:169)
com.atlassian.jira.index.ManagedIndexSearcher.search(ManagedIndexSearcher.java:15)
com.atlassian.jira.issue.search.providers.LuceneSearchProvider.getHitCount(LuceneSearchProvider.java:178)
com.atlassian.jira.issue.search.providers.LuceneSearchProvider.getHitCount(LuceneSearchProvider.java:145)
com.atlassian.jira.bc.issue.search.DefaultSearchService.searchCount(DefaultSearchService.java:130)
......
com.atlassian.greenhopper.service.sprint.SprintPermissionServiceImpl.getIssueCountForSprint(SprintPermissionServiceImpl.java:250)
com.atlassian.greenhopper.service.sprint.SprintPermissionServiceImpl.canViewSprint(SprintPermissionServiceImpl.java:90)
com.atlassian.greenhopper.customfield.sprint.SprintResolver.checkSprintAccessible(SprintResolver.java:31)
com.atlassian.greenhopper.customfield.sprint.SprintResolver$SprintAccessible.apply(SprintResolver.java:139)
com.atlassian.greenhopper.customfield.sprint.SprintResolver$SprintAccessible.apply(SprintResolver.java:125)
com.google.common.base.Predicates$AndPredicate.apply(Predicates.java:353)
The bottleneck appears to be in the following code which will fetch all Sprints available to the user
Set<Sprint> allMatches = check(sprintHelper.findSprintPickerAllMatches(user, suggestions, searchQuery, maxResults, excludeCompleted));
Steps to Reproduce
- Create 500 Sprint with 50,000 issues each (to exaggerate the problem)
- Go to Issue Navigator > Click on Sprint dropdown
- Notice the dropdown appear slowly
Expected Results
A dropdown appears reasonably instantly.
Actual Results
In the extreme, where Jira instance has 3.5M issues and a lot of Sprint, this sprint picker field can take up to 2 minutes to return:
Workaround
- Instead of using the basic JQL search function that allows for the dropdown, switch to the "Advanced" JQL view. When typing out the sprint name, Jira will provide a relevant list of suggestions.
@szarazinski would you please confirm if there any bug fix happened for this issue resolution or shall we consider provided workaround as the fix?