Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-60625

Dashboard rendering blocked on UpdateSite.getJSONObject

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      Jenkins 2.212

      Description

      Recently I have noticed Jenkins page rendering being blocked for a long time (sometimes nearly 30s) with stack traces such as

      "Handling GET /jenkins/ from ... : ... View/index.jelly AdministrativeMonitorsDecorator/footer.jelly" ...
         java.lang.Thread.State: RUNNABLE
      	at java.lang.String.<init>(String.java:207)
      	at java.lang.String.substring(String.java:1933)
      	at net.sf.json.util.JSONTokener.matches(JSONTokener.java:110)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:912)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:156)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
      	at net.sf.json.JSONArray._fromJSONTokener(JSONArray.java:1131)
      	at net.sf.json.JSONArray.fromObject(JSONArray.java:125)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:351)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:955)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:156)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:955)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:156)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:955)
      	at net.sf.json.JSONObject._fromString(JSONObject.java:1145)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:162)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:132)
      	at hudson.model.UpdateSite.getJSONObject(UpdateSite.java:338)
      	at hudson.model.UpdateSite.getData(UpdateSite.java:323)
      	at hudson.model.UpdateCenter.getCoreSource(UpdateCenter.java:604)
      	at hudson.model.UpdateCenter$CoreUpdateMonitor.getData(UpdateCenter.java:1035)
      	at hudson.model.UpdateCenter$CoreUpdateMonitor.isActivated(UpdateCenter.java:1030)
      	at jenkins.model.Jenkins.lambda$getActiveAdministrativeMonitors$0(Jenkins.java:2183)
      	at jenkins.model.Jenkins$$Lambda$103/1298422401.test(Unknown Source)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
      	at java.util.Iterator.forEachRemaining(Iterator.java:116)
      	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
      	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
      	at jenkins.model.Jenkins.getActiveAdministrativeMonitors(Jenkins.java:2188)
      	at jenkins.management.AdministrativeMonitorsDecorator.getActiveAdministrativeMonitors(AdministrativeMonitorsDecorator.java:77)
      	at jenkins.management.AdministrativeMonitorsDecorator.getActiveAdministrativeMonitorsCount(AdministrativeMonitorsDecorator.java:72)
      	at jenkins.management.AdministrativeMonitorsDecorator.shouldDisplay(AdministrativeMonitorsDecorator.java:131)
      

      or

        java.lang.Thread.State: RUNNABLE
      	at java.util.regex.Pattern.compile(java.base@11.0.5/Pattern.java:1757)
      	at java.util.regex.Pattern.<init>(java.base@11.0.5/Pattern.java:1428)
      	at java.util.regex.Pattern.compile(java.base@11.0.5/Pattern.java:1068)
      	at net.sf.json.regexp.JdkRegexpMatcher.<init>(JdkRegexpMatcher.java:38)
      	at net.sf.json.regexp.JdkRegexpMatcher.<init>(JdkRegexpMatcher.java:31)
      	at net.sf.json.regexp.RegexpUtils.getMatcher(RegexpUtils.java:39)
      	at net.sf.json.util.JSONTokener.matches(JSONTokener.java:111)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:912)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:156)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
      	at net.sf.json.JSONArray._fromJSONTokener(JSONArray.java:1131)
      	at net.sf.json.JSONArray.fromObject(JSONArray.java:125)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:351)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:955)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:156)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:955)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:156)
      	at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
      	at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:955)
      	at net.sf.json.JSONObject._fromString(JSONObject.java:1145)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:162)
      	at net.sf.json.JSONObject.fromObject(JSONObject.java:132)
      

      While loading the JSON text from disk takes just milliseconds, the parsing is extremely slow (hundreds of times slower than jq, for example). This seems to be due to poor code in json-lib, especially this which repeatedly compiles patterns where a simple .startsWith("null") would apparently have sufficed!

      The poor performance of JSONObject.fromObject might not have been so noticeable except that some administrative monitors blocked on the parsing, contrary to the Javadoc in AdministrativeMonitor.isActivated.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              jglick Jesse Glick
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: