Closed Bug 1658128 Opened 10 months ago Closed 10 months ago

AddrBookDirectory.childCards and AddrBookDirectory.search do more work than necessary

Categories

(MailNews Core :: Address Book, defect)

defect

Tracking

(thunderbird_esr78? fixed, thunderbird80 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
thunderbird_esr78 ? fixed
thunderbird80 --- fixed

People

(Reporter: standard8, Assigned: standard8)

Details

(Keywords: perf)

Attachments

(1 file)

AddrBookDirectory.childCards and AddrBookDirectory.search both do more work than necessary (I think some of the code could be shared between them, but that's a different bug).

I've noticed two things, the first:

  1. The initially get the full set of card results from the stored list of cards, and then get a card object for each contact which is fed into an array in results variable.
  2. The cards in results are then filtered using an array filter.
  3. At this stage, the code goes and obtains a second list of properties for the card, rather than using the properties that were obtained as part of step 1.

This seems inefficient as it is cloning property maps more than necessary.

The second:

  1. In processing the query, the functions split it up into an array tree first.
  2. The array tree is then iterated over.
  3. Every time we hit a condition element (a string), it is split and then the value is decoded and lower cased.

This third case can be hit many times - in the case of quickSearch from the extension API, I think it is 13 times per card for each card in the database (assuming the contact isn't matched).

We should be able to move those into step 1 and avoid the additional overhead.

Both of these were showing up in performance profiles of Conversations which will sometimes do multiple queries on the address book.

Requesting tracking as this affects regular searches and ones from extensions.

Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/comm-central/rev/b736b95d2018
Avoid extra copying of properties maps and splitting of condition strings in address book searches. r=darktrojan

Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch

Comment on attachment 9168988 [details]
Bug 1658128 - Avoid extra copying of properties maps and splitting of condition strings in address book searches. r?darktrojan!

[Approval Request Comment]
Regression caused by (bug #): Address book changes.
User impact if declined: Performance impact, functionality using quickSearch/Search may be slow.
Testing completed (on c-c, etc.): Landed on c-c.
Risk to taking this patch (and alternatives if risky): Should be low - will be fairly obvious if the function is broken.

Attachment #9168988 - Flags: approval-comm-esr78?
Attachment #9168988 - Flags: approval-comm-beta?

Comment on attachment 9168988 [details]
Bug 1658128 - Avoid extra copying of properties maps and splitting of condition strings in address book searches. r?darktrojan!

[Triage Comment]
Approved for beta

Attachment #9168988 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9168988 [details]
Bug 1658128 - Avoid extra copying of properties maps and splitting of condition strings in address book searches. r?darktrojan!

[Triage Comment]
Approved for esr78

Attachment #9168988 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.