Uploaded image for project: 'Jira Software Server and Data Center'
  1. Jira Software Server and Data Center
  2. JSWSERVER-20445

Sprint picker field causing too much CPU

    XMLWordPrintable

Details

    Description

      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

      1. Create 500 Sprint with 50,000 issues each (to exaggerate the problem)
      2. Go to Issue Navigator > Click on Sprint dropdown
      3. 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:

      xxx.xxx.xxx [14/Feb/2020:08:02:47 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=&_=1581667257699 HTTP/1.1" 200 1233 93952 "https://localhost/jira/browse/FBVRDS-1449" 
      xxx.xxx.xxx [14/Feb/2020:08:02:12 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=&_=1581667222695 HTTP/1.1" 200 1233 95313 "https://localhost/jira/browse/FBVRDS-1448" 
      xxx.xxx.xxx [14/Feb/2020:08:01:04 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=&_=1581667061798 HTTP/1.1" 200 1213 126270 "https://localhost/jira/secure/RapidBoard.jspa?rapidView=88532&selectedIssue=CMBGSAI-10743&quickFilter=129584&quickFilter=142240" 
      xxx.xxx.xxx [14/Feb/2020:08:01:03 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=&_=1581592861732 HTTP/1.1" 200 1262 130847 "https://localhost/jira/secure/RapidBoard.jspa?rapidView=43317&projectKey=HMS&view=planning.nodetail&selectedIssue=HMS-7980&issueLimit=100" 
      xxx.xxx.xxx [14/Feb/2020:08:00:57 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=s&_=1581667061799 HTTP/1.1" 200 1185 118021 "https://localhost/jira/secure/RapidBoard.jspa?rapidView=88532&selectedIssue=CMBGSAI-10743&quickFilter=129584&quickFilter=142240" 
      xxx.xxx.xxx [14/Feb/2020:07:56:12 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=&_=1581666825794 HTTP/1.1" 200 1255 94268 "https://localhost/jira/browse/GCM-8057" 
      xxx.xxx.xxx [14/Feb/2020:07:23:57 +0000] "GET /jira/rest/greenhopper/1.0/sprint/picker?query=&_=1581664229894 HTTP/1.1" 200 1329 101854 "https://localhost/jira/secure/CreateIssue.jspa" 
      

      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.

      Attachments

        1. a.png
          245 kB
          vkharisma
        2. Screen Shot 2020-02-19 at 4.11.39 pm.png
          671 kB
          vkharisma

        Issue Links

          Activity

            People

              szarazinski Sławomir Zaraziński
              vkharisma vkharisma
              Votes:
              38 Vote for this issue
              Watchers:
              52 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: