• 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
performance problem with IORegistryEntryCreateCFProperties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

performance problem with IORegistryEntryCreateCFProperties


  • Subject: performance problem with IORegistryEntryCreateCFProperties
  • From: Brad Justice <email@hidden>
  • Date: Mon, 08 Dec 2008 15:11:49 -0800

My application spawns a POSIX background thread that polls for certain hardware changes. I have found that according to Activity Monitor and BigTop it is consuming about 5% of the CPU, which seems inexplicable to me.

The thread loop calls sleep(2) and then begins its checks. Setting Activity Monitor granularity to 0.5 seconds, I find that every 4 periods the thread consumes 20% of the CPU, and 0 % for the other three. By commenting out sections of code, I have isolated the CPU usage to one loop that executes 7 times. I have confirmed the number of iterations by single stepping in the debugger.In particular, the execution of seven paired calls to IORegistryEntryCreateCFProperties and CFRelease result in 5% CPU usage on my MacBook Pro according to my tools.

Am I misinterpreting my tools, is this an Activity Monitor bug, or are IORegistryEntryCreateCFProperties and CFRelease heavily CPU intensive for some reason? It seems to me seven calls every two seconds should not register activity at this level.

Thanks for any advice that you can provide. Source for the offending loop below.

classToMatch = IOServiceMatching (kIOHIDDeviceKey);
if (classToMatch)
{ numberRef = NULL; mach_port_t mport = [myList getMasterport];
result = IOServiceGetMatchingServices(mport,classToMatch,&iterator);
if (KERN_SUCCESS == result) {
if(iterator)
{
while( ( serviceObject = IOIteratorNext ( iterator ) ) )
{
CFMutableDictionaryRef hidProperties = 0;
result = IORegistryEntryCreateCFProperties (serviceObject, &hidProperties, kCFAllocatorDefault, kNilOptions);
if (result == KERN_SUCCESS)
{
serialNumberValue = (NSString *) CFDictionaryGetValue(hidProperties,CFSTR("SerialNumber"));
if (serialNumberValue != NULL)
{
range = [serialNumberValue rangeOfString:matchingString];
if (range.length != 0)
{
count++;
}
}
}
CFRelease(hidProperties);
}
IOObjectRelease(iterator);
} } }


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: performance problem with IORegistryEntryCreateCFProperties
      • From: "Herb Petschauer" <email@hidden>
    • Re: performance problem with IORegistryEntryCreateCFProperties
      • From: Etienne GuĂ©rard <email@hidden>
  • Prev by Date: NSNumberFormatter strange symbols on PPC/10.4
  • Next by Date: Live updating NSPredicateEditorRowTemplate?
  • Previous by thread: Re: NSNumberFormatter strange symbols on PPC/10.4
  • Next by thread: Re: performance problem with IORegistryEntryCreateCFProperties
  • Index(es):
    • Date
    • Thread