Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance issues with HID driver



One mistake on that... the first slow down is in IOCreatePlugInInterfaceForService, not queryInterface. Poking around in Shark, I'm seeing:

0.0% 100.0% IOKit IOCreatePlugInInterfaceForService
0.0% 99.3% IOHIDLib IOHIDDeviceClass::start (__CFDictionary const*, unsigned)
0.0% 77.1% IOKit IORegistryEntryCreateCFProperties
0.0% 77.1% IOKit IOCFUnserialize
9.3% 74.3% IOKit IOCFUnserializeparse
2.9% 24.3% IOKit IOCFUnserializelex
0.0% 17.1% IOKit buildString
0.0% 15.7% IOKit buildDictionary
0.0% 6.4% IOKit buildNumber
0.0% 0.7% IOKit buildBoolean
0.0% 0.7% IOKit buildArray
0.0% 2.9% CoreFoundation _CFRelease
0.0% 21.4% IOHIDLib IOHIDDeviceClass::BuildElements (__CFDictionary const*, __CFArray*)
0.0% 19.3% IOHIDLib IOHIDDeviceClass::CreateLeafElements (__CFDictionary const*, __CFArray*, void const*, long*, __CFString const*, IOHIDElementStruct*)
0.0% 19.3% CoreFoundation CFArrayApplyFunction
0.0% 19.3% IOHIDLib IOHIDDeviceClass::StaticCreateLeafElements(void const*, void*)
0.0% 19.3% IOHIDLib IOHIDDeviceClass::CreateLeafElements (__CFDictionary const*, __CFArray*, void const*, long*, __CFString const*, IOHIDElementStruct*)
0.0% 18.6% IOHIDLib IOHIDDeviceClass::CreateLeafElements (__CFDictionary const*, __CFArray*, void const*, long*, __CFString const*, IOHIDElementStruct*)
0.7% 0.7% CoreFoundation _CFRelease
0.0% 1.4% IOHIDLib IOHIDDeviceClass::CountElements (__CFDictionary const*, void const*, __CFString const*)
0.0% 0.7% IOHIDLib IOHIDUPSClass::_createAsyncEventSource(void*, void const**)
0.0% 0.7% CoreFoundation _CFRelease
0.0% 0.7% IOKit IOFindPlugIns


The Shark profile looks pretty much the same for IOCreatePlugInInterfaceForService and IORegistryEntryCreateCFProperties.

Thoughts?

Dave

On Jun 21, 2005, at 2:57 PM, Dave Camp wrote:

I've run into some serious performance issues using the hid drivers from my application with some specific keyboards and I'm hoping someone can point me in the right direction.

My application is looking for consumer page button presses on keyboards (the extra buttons for Mail, Documents, etc). It works great on most keyboards (Apple, Logitech, etc). However, on Microsoft keyboards I take a huge CPU hit (7-10 seconds of 100% usage) when I open the HID driver for it, and again when I call IORegistryEntryCreateCFProperties. That's on a 1.25 GHz Mac Mini. Slightly faster on my dual G5, but not much. I see the hit on both 10.3.9 and 10.4.1.

I'm using the following code (edited for mail) to find devices:

ioResult = IOMasterPort(bootstrap_port, &masterPort);
NSMutableDictionary *dict = (NSMutableDictionary*) IOServiceMatching(kIOHIDDeviceKey);


notifyPort = IONotificationPortCreate(masterPort);
CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource(notifyPort);
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode);


[dict retain];
ioResult = IOServiceAddMatchingNotification(notifyPort, kIOFirstMatchNotification, (CFDictionaryRef) dict, DeviceAdded, self, &deviceAddedIter);
ioResult = IOServiceAddMatchingNotification(notifyPort, kIOTerminatedNotification, (CFDictionaryRef) dict, DeviceRemoved, self, &deviceRemovedIter);


    // Run the iterators once to arm them
    ...
    mach_port_deallocate(mach_task_self(), masterPort);

This is the code to open a device that I have matched with: I take a 7-10 second hit in the -> QueryInterface call.

ioResult = IOCreatePlugInInterfaceForService(ioDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score);

plugInResult = (*plugInInterface)->QueryInterface (plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void *) &deviceInterface);
(*plugInInterface)->Release (plugInInterface);


    ioResult = (*deviceInterface)->open(deviceInterface, 0);

And finally, this code gets the properties of the device, which I use to see what buttons are on the device. I take another 7-10 second hit in IORegistryEntryCreateCFProperties.

ioResult = IORegistryEntryCreateCFProperties(ioDevice, (CFMutableDictionaryRef*) &properties, kCFAllocatorDefault, kNilOptions);


As I said, the code only seem to run slow on Microsoft devices. I don't see the performance hit on other brands of hardware.


Using Shark I see the following

14.3% 14.3% mach_kernel OSDictionary::setObject (OSSymbol const*, OSMetaClassBase const*)
0.0% 14.2% mach_kernel OSSerialize::previouslySerialized(OSMetaClassBase const*)
0.0% 14.2% mach_kernel OSSerialize::previouslySerialized(OSMetaClassBase const*)
0.0% 13.1% mach_kernel OSNumber::serialize (OSSerialize*) const
0.0% 13.1% mach_kernel OSDictionary::serialize (OSSerialize*) const
0.0% 13.1% com.apple.iokit.IOHIDFamily IOHIDElementPrivate::serialize(OSSerialize*) const
0.0% 13.1% mach_kernel OSArray::serialize (OSSerialize*) const
0.0% 13.1% mach_kernel OSDictionary::serialize (OSSerialize*) const
0.0% 13.0% com.apple.iokit.IOHIDFamily IOHIDElementPrivate::serialize(OSSerialize*) const
0.0% 13.0% mach_kernel OSArray::serialize (OSSerialize*) const
0.0% 13.0% mach_kernel OSDictionary::serialize (OSSerialize*) const
0.0% 13.0% mach_kernel IORegistryEntry::serializeProperties(OSSerialize*) const
0.0% 13.0% mach_kernel is_io_registry_entry_get_properties
0.0% 13.0% mach_kernel iokit_server_routine
0.0% 13.0% mach_kernel ipc_kobject_server
0.0% 13.0% mach_kernel mach_msg_overwrite_trap
0.0% 13.0% mach_kernel shandler
0.0% 0.0% mach_kernel IORegistryEntry::serializeProperties(OSSerialize*) const
0.0% 0.0% mach_kernel OSArray::serialize(OSSerialize*) const
0.0% 1.1% mach_kernel OSDictionary::serialize (OSSerialize*) const
0.0% 0.1% mach_kernel OSNumber::serialize (OSSerialize*) const
0.0% 0.1% mach_kernel IORegistryEntry::setProperty (OSSymbol const*, OSObject*)


29.8% 29.8% mach_kernel OSDictionary::getObject (OSSymbol const*) const
0.0% 15.0% mach_kernel OSSerialize::addXMLStartTag (OSMetaClassBase const*, char const*)
0.0% 14.6% mach_kernel OSSerialize::previouslySerialized(OSMetaClassBase const*)
0.0% 0.2% mach_kernel OSMetaClass::getMetaClassWithName (OSSymbol const*)


It looks like the driver is spending a lot of time building dictionaries. However, the dictionary size is not terribly different from what I get for an Apple keyboard (~200K vs ~230K).

Any thoughts?

Thanks,
Dave

---
There's an old proverb that says just about whatever you want it to.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden



---
It's not denial. I'm just very particular about the reality I choose to accept. -Calvin


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden
References: 
 >Performance issues with HID driver (From: Dave Camp <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.