Closed Bug 1908761 Opened 1 year ago Closed 1 year ago

Quick Filter stalls computer and takes 10-20 seconds to display results when using certain sort types.

Categories

(Thunderbird :: Folder and Message Lists, defect, P1)

Thunderbird 128
defect

Tracking

(thunderbird_esr115 unaffected, thunderbird_esr128+ fixed, thunderbird130 fixed)

RESOLVED FIXED
131 Branch
Tracking Status
thunderbird_esr115 --- unaffected
thunderbird_esr128 + fixed
thunderbird130 --- fixed

People

(Reporter: gettonoah, Assigned: welpy-cw)

References

(Blocks 1 open bug)

Details

(Keywords: perf, regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0

Steps to reproduce:

Go to folder with 20k+ email and use quick filter

Actual results:

Thunderbird stalls and windows shows as not responding for 10-20 seconds until it is able to display results. Performance capture here: https://profiler.firefox.com/public/kysamrkxp4d55z9p3fqyyqj1491njepjc9f0s7r/calltree/?globalTrackOrder=01&thread=0&v=10

Expected results:

In all prior versions the quick filter was almost instant with no stalling.

Noah, what sort column and order is being used on this folder of 22k messages?

The displayed columns, in order, are: Thread (set to unthreaded), read status, attachments, correspondents, date and size.
Folder is sorted by date with newest at the bottom.

Let me me know if you need more info.

Flags: needinfo?(gettonoah)

In the profile we can see that this involves JS -> C++ -> JS logic. And we can also see that we're spending about 500ms per call in parseDecodedHeader, and half of that in getHeaderTokens. There are also two massive GCs during the 10s we spend sorting in nsMsgDBView::Sort (which calls the previously mentioned parseDecodedHeader with GetCollationKey, which uses IsOutgoingMsg that leads us to try and decode the mime header).

I'm not familiar enough with this part of code to go any further than that, but maybe we should avoid trying to parse the headers for the code path we use for sorting of messages? Surely we already have the information in the DB?

Component: Toolbars and Tabs → Folder and Message Lists

Noah, can you please try the following workaround and report back:

  1. Select column "Order received" to display.
  2. Click on "Order received" column header.
  3. Click on "Date" column header.

This should be the fastest combination of primary and secondary sort types. Regarding the performance profile Martin is talking about, my guess is that the secondary sort was (unintentionally) set to by "Correspondent", which currently has the most severe performance issues.

Flags: needinfo?(gettonoah)

See my comment in bug 1908758 comment #4.

See Also: → 1055077

(In reply to Hartmut Welpmann [:welpy-cw] from comment #5)

Noah, can you please try the following workaround and report back:

  1. Select column "Order received" to display.
  2. Click on "Order received" column header.
  3. Click on "Date" column header.

Since I'm affected by this bug too, I tried out a similar approach and first clicked on the "Size" column (didn't want to add the "Order received" column") and then on the "Date" column and I can confirm that Quick Filter works much, much faster after that. HTH.

Confirmed that worked. Interestingly after sorting by order received then date, I'm unable to replicate the slowdown by any means including going back to my prior "received" sort, so this looks like a permanent fix.

(In reply to HK-47 from comment #9)

Confirmed that worked. Interestingly after sorting by order received then date, I'm unable to replicate the slowdown by any means including going back to my prior "received" sort, so this looks like a permanent fix.

Don't know why it double-posted, please delete the dupe.

Wanted to add that I made the change via the system menu "View | Sort By" as I use the vertical cards view. That worked fine.

To set the secondary sort, DBViewWrapper lets the view sort itself twice in many cases such as
entering/leaving Quick Filter or leaving Grouped By Sort, as well as just changing the sort type
itself. Since nsMsgDBView::Sort() already takes the secondary sort into account, these
additional calls can be removed, which can significantly improve performance depending on the
individual sort types.

When leaving Grouped By Sort, the secondary sort type will always be set to Order Received, which
prevents having a comparably slow sort type such as by From, Recipient, or Correspondents as
secondary sort in place.

Duplicate of this bug: 1908758
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Quick Filter Stalls Computer and Takes 10-20 seconds to display results → Quick Filter stalls computer and takes 10-20 seconds to display results when using certain sort types.

(In reply to R de Wit from comment #7)

(In reply to Hartmut Welpmann [:welpy-cw] from comment #5)

Noah, can you please try the following workaround and report back:

  1. Select column "Order received" to display.
  2. Click on "Order received" column header.
  3. Click on "Date" column header.

Since I'm affected by this bug too, I tried out a similar approach and first clicked on the "Size" column (didn't want to add the "Order received" column") and then on the "Date" column and I can confirm that Quick Filter works much, much faster after that. HTH.

Just tried this along with removing the "Correspondents" column and using the recipient (for sent mail folder) and it's snappy again. I had already had it sorted by date prior to adding the order received column and while that didn't appear to change the order vs the date, it works now even after bringing back correspondents.

Thank you all!

Flags: needinfo?(gettonoah)

Following the workaround steps in this has resolved this issue for me, making TB quickfilter usable again in 128. Thanks!

This is borderline S2. If this is what is shipping out to users now, definitely S2 severity.

Great finding and exploration in this bug, thank you all for your valuable help.
Welpy, do you have any intuition or potential approach on what the performance problem in the Correspondent field is and if you identified any pointer on how to tackle it?

I'm gonna leave this as S3 because Correspondent is not a default sorting order and (I don't think) we changed it during upgrade, so users that haven't changed the default will not be affected, and an easy workaround exists.

Setting P1 so we can try to tackle it before the next point release.

Flags: needinfo?(alessandro)
Priority: -- → P1
Assignee: nobody → h.w.forms
Attachment #9416611 - Attachment description: WIP: Bug 1908761 - Simplify and improve handling of secondary sorts in DBViewWrapper. → Bug 1908761 - Simplify and improve handling of secondary sorts in DBViewWrapper. r=#thunderbird-reviewers
Status: NEW → ASSIGNED

(In reply to Alessandro Castellani [:aleca] from comment #16)

Welpy, do you have any intuition or potential approach on what the performance problem in the Correspondent field is and if you identified any pointer on how to tackle it?

https://searchfox.org/comm-central/rev/3554a691473aa58c8430d879a2749489194bf96d/mailnews/db/msgdb/src/nsMsgDatabase.cpp#2998-2999,3005
https://searchfox.org/comm-central/rev/3554a691473aa58c8430d879a2749489194bf96d/mailnews/base/src/nsMsgDBView.cpp#466,498-499
https://searchfox.org/comm-central/rev/3554a691473aa58c8430d879a2749489194bf96d/mailnews/base/src/nsMsgDBView.cpp#856,862

These functions, which are needed to process message headers containing addresses, rely on JSMime. Each call to DecodedHeader or EncodedHeader involves some XPConnect overhead, which adds up to a significant amount. For a possible approach see bug 1089299.

See Also: → 1089299

(Essentially what Martin already discovered in comment 4)

(In reply to Alessandro Castellani [:aleca] from comment #16)

I'm gonna leave this as S3 because Correspondent is not a default sorting order and (I don't think) we changed it during upgrade, so users that haven't changed the default will not be affected, and an easy workaround exists.

Not sorting, or even showing "Correspondent" here!

Blocks: 1893571

(In reply to Worcester12345 from comment #19)

(In reply to Alessandro Castellani [:aleca] from comment #16)

I'm gonna leave this as S3 because Correspondent is not a default sorting order and (I don't think) we changed it during upgrade, so users that haven't changed the default will not be affected, and an easy workaround exists.

Not sorting, or even showing "Correspondent" here!

The underlying cause identified in this bug is about sorts by From, Recipient, or Correspondents. Each of them is slower than other sort types, especially when active as secondary sort. So if the workaround provided in comment 5 doesn't have any effect for you, there is another cause.

By the way, I did some tests with a slow debug build. The issue is most obvious when leaving quick filter. These are the rough measurements for about 8000 unthreaded messages in a local folder:

primary sort secondary sort without patch with patch
Date Corresp. 37s 1s (!)
Subject Corresp. 52s 17s
Corresp. Subject 13s 9s

I don't think this is the case for me. I don't even know what a "secondary sort" is or how to turn it on. I don't think I've ever used that.

This is absolutely KILLING use of email. I hope other users here are not having the same thing.

Oh, I wanted to add, this is pretty new. I don't recall it doing this before version 128 came out.

@Worcester12345: Please note what "secondary sort" is. It's always active, no need to turn it on, and if you ever sorted by a column, you have used it. Here's the story via example. If you first sort by date ascending and then by sender, you will get all the mail sent by a specific person "sorted together" and inside the "group", sorted by date ascending. Date ascending is the secondary sort. If you first sort by date descending and then by subject, you get a different result. This functionality has existed for decades, sadly there is no secondary sort indicator, so many people don't recognise the hidden feature.

IOW: A secondary sort can "hang around" and you don't even notice.

How does one turn this off? Click the column twice?
This is taking MINUTES to just do what took SECONDS a week ago.
It is absolutely killing productivity!!!!!!!!!
This is on a live production system, not "beta", not "nightly".

(In reply to Worcester12345 from comment #24)

How does one turn this off? Click the column twice?
This is taking MINUTES to just do what took SECONDS a week ago.
It is absolutely killing productivity!!!!!!!!!
This is on a live production system, not "beta", not "nightly".

For me, following the instructions in comment 5 of this thread resolved the issue. https://bugzilla.mozilla.org/show_bug.cgi?id=1908761#c5

(In reply to laurence.norah from comment #25)

(In reply to Worcester12345 from comment #24)

How does one turn this off? Click the column twice?
This is taking MINUTES to just do what took SECONDS a week ago.
It is absolutely killing productivity!!!!!!!!!
This is on a live production system, not "beta", not "nightly".

For me, following the instructions in comment 5 of this thread resolved the issue. https://bugzilla.mozilla.org/show_bug.cgi?id=1908761#c5

That did indeed stop the symptoms for me. I am not going to try to explain this to a bunch of users, though. It still needs a real fix.

I'm going to review the proposed patches and do some profile testing.
If everything is good we will uplift this to 128 for the next point release.

See Also: → 1911212
See Also: → 1911048
See Also: → 1733234

We also encountered this issue. It is relevant even after a clean installation of Thunderbird, with the number of emails ranging from 20 to 60 thousand in a folder. This applies to both maildir and mbox email storage options, and it does not depend on the performance of the computer.

Target Milestone: --- → 131 Branch

Pushed by brendan@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/cb5dead87b07
Simplify and improve handling of secondary sorts in DBViewWrapper. r=aleca,babolivier

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

We got a new failure that it might be related to this patch, but I'm not sure, and it seems to happen only on Windows debug builds.
Anyone able to reproduce it locally?
Bug 1911891

Duplicate of this bug: 1912165
Duplicate of this bug: 1912013
Regressions: 1911891

Is bug 1911891 a bad regression? If not, we should proceed to uplift this P1 to beta and 128.

Flags: needinfo?(h.w.forms)

(In reply to Wayne Mery (:wsmwk) from comment #33)

Is bug 1911891 a bad regression?

Not at all, in my opinion. While the automatic test fails (only) on the Win32 Debug build, the feature itself appears to work using the exact same build.

If not, we should proceed to uplift this P1 to beta and 128.

D'accord.

Flags: needinfo?(h.w.forms)

Comment on attachment 9416611 [details]
Bug 1908761 - Simplify and improve handling of secondary sorts in DBViewWrapper. r=#thunderbird-reviewers

[Triage Comment]

[Approval Request Comment]
Regression caused by (bug #): -
User impact if declined: TB is very slow
Testing completed (on c-c, etc.): 2 weeks on nightly
Risk to taking this patch (and alternatives if risky): low, has tests

Flags: needinfo?(corey)
Attachment #9416611 - Flags: approval-comm-beta?

Comment on attachment 9416611 [details]
Bug 1908761 - Simplify and improve handling of secondary sorts in DBViewWrapper. r=#thunderbird-reviewers

[Triage Comment]
Approved for beta

Flags: needinfo?(corey)
Attachment #9416611 - Flags: approval-comm-beta? → approval-comm-beta+
Duplicate of this bug: 1915180
See Also: → 1912077
Duplicate of this bug: 1915016

128 uplift is needed given the widely reported impact to users

Flags: needinfo?(corey)

Comment on attachment 9416611 [details]
Bug 1908761 - Simplify and improve handling of secondary sorts in DBViewWrapper. r=#thunderbird-reviewers

[Triage Comment]
Approved for esr128 for severe performance issue

Flags: needinfo?(corey)
Attachment #9416611 - Flags: approval-comm-esr128+
Duplicate of this bug: 1911048
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: