Closed Bug 1854035 Opened 1 year ago Closed 1 year ago

Startup Performance degradation for Unified Folders caused by bug 1847401

Categories

(Thunderbird :: Folder and Message Lists, defect)

Thunderbird 115
Unspecified
All
defect

Tracking

(thunderbird_esr115 fixed)

RESOLVED FIXED
119 Branch
Tracking Status
thunderbird_esr115 --- fixed

People

(Reporter: betterbird.project+10, Assigned: darktrojan)

References

(Regression)

Details

(Keywords: perf, regression, Whiteboard: [regression: 115.2.3/118.0b5])

Attachments

(2 files)

Attached image profiling.png

+++ This bug was initially created as a clone of Bug #1847401 +++

TB 115.2.3 shows a significant performance degradation at startup on a profile with about ~1500 folders.

Profiling shows that a lot of time is spent in getRowForFolder() and its query selector code.

Looks like the code added has a performance of O(n^2) in initServer() since in a loop over the folders, all folders in the tree are visited.

If now takes about 8 seconds to show the first window. Note that in the picture the red bars are labelled as yanks.

Keywords: regression
Regressed by: 1847401
Assignee: nobody → geoff
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

This is certainly better. However, there are still mass operations run in loops:

      initServer(server) {
        // Find all folders in this server that aren't currently displayed.
        let existingRows = new Set(
          Array.from(
            this.containerList.getElementsByTagName("li"),
            li => li.uri
          )
        );
        console.log("=== initServer existingRows.size (1)", existingRows.size);
        let remainingFolderURIs = server.rootFolder.descendants
          .map(folder => folder.URI)
          .filter(folderURI => !existingRows.has(folderURI));
        console.log("=== initServer remainingFolderURIs.length (1)", remainingFolderURIs.length);

        while (remainingFolderURIs.length) {
          let folderURI = remainingFolderURIs.shift();
          let folder = MailServices.folderLookup.getFolderForURL(folderURI);
          if (folderPane._isGmailFolder(folder)) {
            continue;
          }
          this.addFolder(folderPane._getNonGmailParent(folder), folder);

          existingRows = new Set(
            Array.from(
              this.containerList.getElementsByTagName("li"),
              li => li.uri
            )
          );
          console.log("=== initServer existingRows.size (2)", existingRows.size);
          remainingFolderURIs = remainingFolderURIs.filter(
            folderURI => !existingRows.has(folderURI)
          );
          console.log("=== initServer remainingFolderURIs.length (2)", remainingFolderURIs.length);
        }
      },

existingRows and remainingFolderURIs are constantly rebuilt and their sizes increase/decrease each time. Instead of rebuilding those arrays, can the existing arrays be used?

Target Milestone: --- → 119 Branch

Pushed by martin@humanoids.be:
https://hg.mozilla.org/comm-central/rev/a9682111c027
Improve perfomance of Unified Folder mode initialisation. r=freaktechnik

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED

Comment on attachment 9354036 [details]
Bug 1854035 - Improve perfomance of Unified Folder mode initialisation. r=freaktechnik

[Triage Comment]
Approved for beta

Attachment #9354036 - Flags: approval-comm-beta+

Comment on attachment 9354036 [details]
Bug 1854035 - Improve perfomance of Unified Folder mode initialisation. r=freaktechnik

[Triage Comment]
Approved for esr115 per matrix

Attachment #9354036 - Flags: approval-comm-esr115+
Whiteboard: [regression: 115.2.3/118.0b5]
Summary: Performance degradation caused by bug 1847401 → Startup Performance degradation for Unified Folders caused by bug 1847401
Target Milestone: 119 Branch → Thunderbird 60.0
Target Milestone: Thunderbird 60.0 → 119 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: