Re: Retrieving the EXIF date/time from 250k images
Re: Retrieving the EXIF date/time from 250k images
- Subject: Re: Retrieving the EXIF date/time from 250k images
- From: Mike Abdullah via Cocoa-dev <email@hidden>
- Date: Thu, 18 Aug 2022 13:47:31 +0200
It’s not a very good fit, but when you say a “GCD concurrent queue”, you’d need
to be more specific. There are several configs possible. Do you mean a global
queue, or one you made yourself? If you made it yourself, how did you configure
it?
The tricky problem is that GCD aims to optimise CPU usage. Reading image
metadata from disk is almost certainly not CPU bound; it’s going to be limited
by disk speed and the file system instead. GCD will have a tendency to see
tasks blocked on doing this, not occupying the CPU, and so spin up another task
in the hope that one _will_ then use the CPU, eventually grinding to a halt as
a huge number of threads contend for access to the file system.
Some kind of limit is wise.
You may also wish to look at dispatch_apply(), which does work in parallel, but
via a serial API. It’s a concurrent version of a for loop.
Even better, for what you’re asking for, there’s a very good chance that
Spotlight has the info you want indexed and on-hand. You can look into whether
that is available via an API as a fast path to take when possible.
Mike.
> On 17 Aug 2022, at 20:32, James Crate via Cocoa-dev
> <email@hidden> wrote:
>
> I have an app that does some image processing, and when I tried to use GCD it
> created several hundred threads which didn’t work very well. NSOperationQueue
> allows you to set the max concurrent operations, and the batch exporting
> process fully utilizes all logical cores on the CPU.
>
> opsQueue.maxConcurrentOperationCount =
> NSProcessInfo.processInfo.processorCount;
>
> Maybe I was using GCD wrong, or maybe reading, processing, and writing
> several hundred images is not a good fit for GCD concurrent queue? In any
> case NSOperationQueue is easy to use and works well.
>
> Jim Crate
_______________________________________________
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