• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: RESEND: NSMetadataItem performance issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RESEND: NSMetadataItem performance issues


  • Subject: Re: RESEND: NSMetadataItem performance issues
  • From: Chris Kane <email@hidden>
  • Date: Wed, 10 Aug 2005 08:16:34 -0700

On Aug 3, 2005, at 9:55 AM, Vince DeMarco wrote:

On Aug 2, 2005, at 5:05 PM, Hamish Allan wrote:

On 3 Aug 2005, at 00:46, Vince DeMarco wrote:

kMDItemPaths isn't cached its generated on the client as you need it. So asking for kMDItemPath is going to be slow, only ask for the Path of an item when you absolutely need it don't do it always.



Thanks for your reply. I was actually surprised at how fast it was to obtain kMDItemPaths in general: the problem is that in certain situations it's not just slow, but it takes 1 second for each attribute to be fetched -- not just kMDItemPath but kMDItemDisplayName, etc. It only appears to happen when valueForAttribute: is called in the table redrawing code, i.e. at the end of the run loop, which combined with the execution time of almost exactly 1000ms made me think it might be a mutex issue? And it mostly happens when lots of NSMetadataItems have previously been fully instantiated describing the same results.



You get this quickly you need to do a bulk fetch using the Sortiing attributes of MDQueryRef() and the two calls.


MD_EXPORT CFIndex MDQueryGetIndexOfResult(MDQueryRef query, const void *result) MD_AVAIL;
and
MD_EXPORT const void *MDQueryGetResultAtIndex(MDQueryRef query, CFIndex idx) MD_AVAIL;


Its not a mutex issue, each call to MDItemCopyAttribute() involves a mach_message to the server, a context switch and a mach_message back to you to return the result.


To put Vince's suggestion in NSMetadataQuery terms, if you know that you are going to be looking at certain attributes all the time, you should tell NSMetadataQuery you are going to use them, and then those attributes will be prefetched. Or put another way, when you set "valueListAttributes", "groupingAttributes", and "sortDescriptors" on an NSMetadataQuery, it will prefetch the attributes in those lists so that access is faster. To get the prefetched attributes, you need to use -valueOfAttribute:forResultAtIndex: on the NSMetadataQuery, not ask the NSMetadataItems, because it is the Query object which is caching results based on the query.

However, you should not go and through EVERY attribute you MIGHT want to display or use into one of these lists just to get it prefetched -- that will just start slowing things down again as more and more data needs to be transported, plus the memory usage in your app will bloat, which will also slow things down. Attributes you don't use or display until the user clicks on one of the items or whatever you shouldn't prefetch.

Now with kMDItemPath, I thought that previous discussion on this list had established that that attribute is special, and cannot be prefetched due to its computational complexity. Don't implement your data structures around kMDItemPath if you can avoid it.


Chris Kane Cocoa Frameworks, Apple

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSMetadataItem performance issues
      • From: Hamish Allan <email@hidden>
References: 
 >RESEND: NSMetadataItem performance issues (From: Hamish Allan <email@hidden>)
 >Re: RESEND: NSMetadataItem performance issues (From: Vince DeMarco <email@hidden>)
 >Re: RESEND: NSMetadataItem performance issues (From: Hamish Allan <email@hidden>)
 >Re: RESEND: NSMetadataItem performance issues (From: Vince DeMarco <email@hidden>)

  • Prev by Date: Re: Core Data SQL store looses data that XML store does not
  • Next by Date: Re: Something like runUntilDate in CoreFoundation
  • Previous by thread: Re: NSMetadataItem performance issues
  • Next by thread: Re: NSMetadataItem performance issues
  • Index(es):
    • Date
    • Thread