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: James Crate via Cocoa-dev <email@hidden>
- Date: Thu, 18 Aug 2022 11:47:21 -0400
On Aug 18, 2022, at 7:47 AM, Mike Abdullah <email@hidden> wrote:
>
> 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?
Like Alex, for me this was 10-12 years ago so I don’t remember much about
exactly how I tried to use GCD. It spun up too many threads, I re-read the docs
and assumed it was spinning up new threads based on file IO blocking, and
killing itself. I didn’t see a handy way to limit GCD concurrent queueing, and
NSOperationQueue had maxConcurrentOperationCount documented. NSOperationQueue
was also more idiomatic Objective-C and easier to use/understand in an Obj-C
program.
> 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.
In my case the app reads hundreds images from disk or network file share,
performs operations (scale/rotate/crop/etc), rendering on CPU (better accuracy
for printing) and writing to disk or network share. Perfect fit for
NSOperationQueue with maxConcurrentOperationCount, so I was grateful someone at
Apple had already done the hard work and made concurrent programming much
easier for people with tasks like mine.
The OP is just grabbing image metadata but would almost certainly run into the
same problem using GCD's dispatch_async so they’ll also be much better off
using NSOperationQueue with maxConcurrentOperationCount.
Jim Crate
> 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