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

Slow performance of warnings table if there are 1000 elements

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • warnings-ng-plugin
    • None

      Currently, the whole table is loaded into the client's browser using an Ajax call:

      JS side (issues-detail.js):

      var tabToggleLink = $('a[data-toggle="tab"]');
                  tabToggleLink.on('show.bs.tab', function (e) {
                      var activeTab = $(e.target).attr('href');
                      if (activeTab === (id + 'Content') && dataTable.data().length === 0) {
                          view.getTableModel(id, function (t) {
                              (function ($) {
                                  var table = $(id).DataTable();
                                  table.rows.add(t.responseObject().data).draw()
                              })(jQuery);
                          });
                      }
                  });
      

      Java side (IssuesDetail):

         /**
           * Returns the UI model for the specified table.
           *
           * @param id
           *         the ID of the table
           *
           * @return the UI model as JSON
           */
          @JavaScriptMethod
          @SuppressWarnings("unused") // Called by jelly view
          public JSONObject getTableModel(final String id) {
              List<List<String>> rows;
              if ("#issues".equals(id)) {
                  rows = getIssuesModel().getContent(getIssues());
              }
              else {
                  rows = getScmModel().getContent(getIssues());
              }
      
              return toJsonArray(rows);
          }
      

      Pagination is currently only available on the client side:

                  var dataTable = table.DataTable({
                      language: {
                          emptyTable: "Loading - please wait ..."
                      },
                      pagingType: 'numbers',  // Page number button only
                      order: [[1, 'asc']],
                      columnDefs: [{
                          targets: 0,         // First column contains details button
                          orderable: false
                      }]
                  });
      
      

      For a larger number of issues it would make sense to replace this part of the code with a server side pagination:

      • Client rather requests the content of the selected page
      • Server returns a page of the current results (staring at the given position, using a given page size)

          [JENKINS-49965] Slow performance of warnings table if there are 1000 elements

          Ulli Hafner created issue -
          Ulli Hafner made changes -
          Epic Link New: JENKINS-49911 [ 188901 ]
          Ulli Hafner made changes -
          Rank New: Ranked lower
          Ulli Hafner made changes -
          Rank New: Ranked lower
          Ulli Hafner made changes -
          Epic Link Original: JENKINS-49911 [ 188901 ]
          Ulli Hafner made changes -
          Component/s New: warnings-ng-plugin [ 24526 ]
          Component/s Original: analysis-core-plugin [ 15709 ]
          Ulli Hafner made changes -
          Link New: This issue relates to JENKINS-55513 [ JENKINS-55513 ]
          Ulli Hafner made changes -
          Rank New: Ranked lower
          Ulli Hafner made changes -
          Rank New: Ranked lower
          Ulli Hafner made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]
          Ulli Hafner made changes -
          Description New: Currently, the whole table is loaded into the clients browser using an Ajax call:

          JS side ([issues-detail.js|https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/main/webapp/js/issues-detail.js#L308]):

          {code}
          var tabToggleLink = $('a[data-toggle="tab"]');
                      tabToggleLink.on('show.bs.tab', function (e) {
                          var activeTab = $(e.target).attr('href');
                          if (activeTab === (id + 'Content') && dataTable.data().length === 0) {
                              view.getTableModel(id, function (t) {
                                  (function ($) {
                                      var table = $(id).DataTable();
                                      table.rows.add(t.responseObject().data).draw()
                                  })(jQuery);
                              });
                          }
                      });
          {code}

          Java side ([IssuesDetail|https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/main/java/io/jenkins/plugins/analysis/core/model/IssuesDetail.java#L210]):
          {code}
             /**
               * Returns the UI model for the specified table.
               *
               * @param id
               * the ID of the table
               *
               * @return the UI model as JSON
               */
              @JavaScriptMethod
              @SuppressWarnings("unused") // Called by jelly view
              public JSONObject getTableModel(final String id) {
                  List<List<String>> rows;
                  if ("#issues".equals(id)) {
                      rows = getIssuesModel().getContent(getIssues());
                  }
                  else {
                      rows = getScmModel().getContent(getIssues());
                  }

                  return toJsonArray(rows);
              }
          {code}

          Pagination is currently only available on the client side:

          {code}
                      var dataTable = table.DataTable({
                          language: {
                              emptyTable: "Loading - please wait ..."
                          },
                          pagingType: 'numbers', // Page number button only
                          order: [[1, 'asc']],
                          columnDefs: [{
                              targets: 0, // First column contains details button
                              orderable: false
                          }]
                      });

          {code}

          For a larger number of issues it would make sense to replace this part of the code with a server side pagination:
          * Client rather requests the content of the selected page
          * Server returns a page of the current results (staring at the given position, using a given page size)

            drulli Ulli Hafner
            drulli Ulli Hafner
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: