Closed Bug 403256 Opened 19 years ago Closed 18 years ago

Make nsIAddressBook a service and keep the root rdf address book alive.

Categories

(MailNews Core :: Address Book, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9.1a2

People

(Reporter: standard8, Assigned: standard8)

References

Details

(Keywords: perf)

Attachments

(6 files, 3 obsolete files)

Bug 379828 comment 62 has highlighted that if we don't keep a reference to the root rdf address book (moz-abdirectory://) alive, then every time we want to access it or the other directories, we're loading them all in and re-initialising them from scratch. Obviously re-initialising them from scratch is expensive (see http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/mailnews/addrbook/src/nsAbBSDirectory.cpp&rev=1.40&mark=134-186#132 for where it starts). For the moment, we're getting around this by storing a cache in nsMsgContentPolicy, we should really do this in nsIAddressBook with nsIAddressBook being a service (currently we create a new instance of it each time. I think this may slow down start-up time slightly (or first access), but would give us a big advantage over our current speed issues. For this to happen, we need to drop its inheritance of nsIContentHandler and nsIStreamLoaderObserver (which access it via createInstance) which means moving that code elsewhere - possibly to a js component.
Attached patch The fix (obsolete) — — Splinter Review
This changes nsIAddressBook into a service. I think I've got all the calls changed - I'm going to check tomorrow on mxr, assuming I have, then I'll request review.
Attached patch The fix v2 (obsolete) — — Splinter Review
This patch includes a couple of changes in mailnews/addrbook/prefs that I'd previously missed. I'm happy I've got all the changes. Interestingly palm sync already gets nsIAddressBook as a service... Note that the content handler code, I've just moved straight out into its own class (so that it can be called safely via createInstance), and re-organised the includes in nsAddressBook as a result. Although moving content handler out does give us some losses in terms of code size etc, I'm hoping to gain that back real soon by merging nsIAddrBookSession into nsIAddressBook. nsIAddrBookSession is an already existing service that deals with address book level notifications etc, so it seems to make sense to merge them together - I'll cover that in a separate bug though.
Attachment #290151 - Attachment is obsolete: true
Attachment #290224 - Flags: review?(neil)
Comment on attachment 290224 [details] [diff] [review] The fix v2 >-[scriptable, uuid(0823e46e-8802-42d5-b91b-7e4816c8d2f0)] >+[scriptable, uuid(bf83d970-1697-40ad-aad1-3b0606957c32)] I suppose this change is to alert people to use it as a service? > nsAbLDIFService.cpp \ >+ nsAbContentHandler.cpp \ > $(NULL) Heh, funky indentation here ;-) >+#define EXPORT_ATTRIBUTES_TABLE_COUNT 51 Can we change this to an NS_ARRAY_LENGTH? >+ addressbook = Components.classes["@mozilla.org/addressbook;1"] >+ .getService(Components.interfaces.nsIAddressBook); When you're reindenting these is it possible to line them up like this? addressbook = Components.classes["@mozilla.org/addressbook;1"] .getService(Components.interfaces.nsIAddressBook);
Attachment #290224 - Flags: review?(neil) → review+
Addressed Neil's comments, carrying forward his r, requesting sr.
Attachment #290224 - Attachment is obsolete: true
Attachment #290422 - Flags: superreview?(mscott)
Attachment #290422 - Flags: review+
Comment on attachment 290422 [details] [diff] [review] The fix v3 (checked in) Switching sr request to David as I'd like to move this on a bit.
Attachment #290422 - Flags: superreview?(mscott) → superreview?(bienvenu)
Comment on attachment 290422 [details] [diff] [review] The fix v3 (checked in) Maybe this isn't possible for compatibility reasons, but it sure would be nice to have a different name, like nsIAddressBookMgr or Service - as it is now, the code still reads like we're creating an address book instance and will continue to confuse folks.
Attachment #290422 - Flags: superreview?(bienvenu) → superreview+
Comment on attachment 290422 [details] [diff] [review] The fix v3 (checked in) Checked in, I also backed out a printf that shouldn't have been there.
Attachment #290422 - Attachment description: The fix v3 → The fix v3 (checked in)
David suggested renaming nsIAddressBook so it more accurately reflects what we are doing (i.e. a manager or service). We had a quick chat on irc and I think we settled on nsIAbManager. So here's the code that'll do the change. In the first instance, I'm just doing search & replace (based on my previous patch) - once we've got the change checked in, then I'll arrange a separate patch for sorting out cvs copies & renaming the ns?AddressBook* files.
Attachment #292239 - Flags: superreview?(bienvenu)
Attachment #292239 - Flags: review?(neil)
Comment on attachment 292239 [details] [diff] [review] Rename nsIAddressBook to nsIAbManager (checked in) >- nsAddressBook::RegisterProc, >- nsAddressBook::UnregisterProc }, >+ nsAbManager::RegisterProc, >+ nsAbManager::UnregisterProc }, These are obsolete (see attachment 275769 [details] [diff] [review]) r=me with them removed.
Attachment #292239 - Flags: review?(neil) → review+
cvs moves file to rename nsAddressBook.{h,cpp} to nsAbMananger.{h,cpp}. I think we need this to save confusion. I'll attach the final build changes once the main rename patch is approved & checked in.
Attachment #292654 - Flags: superreview?(bienvenu)
Attachment #292654 - Flags: review?(neil)
Comment on attachment 292654 [details] [diff] [review] cvs moves for nsAddressBook to nsAbManager What about nsIAddressBook -> nsIAbManager?
(In reply to comment #11) > (From update of attachment 292654 [details] [diff] [review]) > What about nsIAddressBook -> nsIAbManager? > I knew I forgot something.
Attachment #292654 - Attachment is obsolete: true
Attachment #292654 - Flags: superreview?(bienvenu)
Attachment #292654 - Flags: review?(neil)
Include the interface file as well this time... As before I'll do the final patch to do the build changes for the move once the first patch is approved & checked in (as its easier ;-) ).
Attachment #292799 - Flags: superreview?(bienvenu)
Attachment #292799 - Flags: review?(neil)
Attachment #292799 - Flags: review?(neil) → review+
Comment on attachment 292239 [details] [diff] [review] Rename nsIAddressBook to nsIAbManager (checked in) thx a lot for doing this, Mark.
Attachment #292239 - Flags: superreview?(bienvenu) → superreview+
Attachment #292799 - Flags: superreview?(bienvenu) → superreview+
Attachment #292239 - Attachment description: Rename nsIAddressBook to nsIAbManager → Rename nsIAddressBook to nsIAbManager (checked in)
I think only one person needs to look at this.
Attachment #293002 - Flags: superreview?(neil)
Attachment #293002 - Flags: review?(neil)
Depends on: 408255
Attachment #293002 - Flags: superreview?(neil)
Attachment #293002 - Flags: superreview+
Attachment #293002 - Flags: review?(neil)
Attachment #293002 - Flags: review+
Attachment #293002 - Attachment description: Change file inclusion for nsIAbManager after the cvs copies/moves. → Change file inclusion for nsIAbManager after the cvs copies/moves (checked in)
Priority: -- → P3
Product: Core → MailNews Core
Bug 449618 will be removing the cache we added in in bug 379828 for the top-level address book (so that the rdf service didn't keep dropping & re-initialising the directories). Therefore I need to get round to fixing this bug ;-) I have just been doing some testing. Opening up (and keeping) an address book with 5000 full entries in it expanded the memory in use ("Real Memory" as Mac OS X calls it) by approx 6MB. The mork file is about 3.3MB. However, it should be noted that if you disable the current cache that we have in bug 379828, then what happens on current trunk is as follows: * If in TB, when you select a message, the personal address book gets cached and stays like it until you shut down (this is in the header processing code, where we are working out whether or not to show the display name). * In either SM/TB when you go into the address book and select a directory (or the sidebar) it is opened and cached. I therefore don't think its too much of a "regression" that we are caching the directories, as we do a lot of that already. Additionally, on trunk with the changes in bug 379828 we would have been doing that anyway. So I think it is reasonable to cache it in nsAbManager, obviously when we implement sqlite or remove RDF from the address book completely, it will be something to think about a bit more.
Attachment #333919 - Flags: superreview?(bienvenu)
Attachment #333919 - Flags: review?(bienvenu)
Attachment #333919 - Flags: superreview?(bienvenu)
Attachment #333919 - Flags: superreview+
Attachment #333919 - Flags: review?(bienvenu)
Attachment #333919 - Flags: review+
Comment on attachment 333920 [details] [diff] [review] [checked in] Cache the top-level address book in the manager Checked in changeset id: 106:f46fea54c2d5
Attachment #333920 - Attachment description: Cache the top-level address book in the manager → [checked in] Cache the top-level address book in the manager
This is fixed now.
Target Milestone: --- → mozilla1.9.1a2
(In reply to comment #19) > This is fixed now. Means we can also set the status to fixed?
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: