bugGNUstep - Bugs: bug #47926, Poor performance in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #47926: Poor performance in NSOperationQueue

Submitted by:  Larry Campbell <lcampbel>
Submitted on:  Sun 15 May 2016 08:53:00 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: In Test

Mon 18 Jul 2016 10:16:54 AM UTC, comment #3:

I was hoping for a patch, but I finally got round to trying to implement this myself anyway; svn trunk should keep the waiting operation array sorted by inserting in the correct position and observing the queuePriority of each operation (and repositioning operations in the queue when their priority changes).

Richard Frith-Macdonald <CaS>
Project Member
Mon 16 May 2016 04:16:42 PM UTC, comment #2:

You have a good point, which I did consider. In my applications I don't use setQueuePriority:, so the fix I proposed is sufficient for me. You're right that it would be better to observe the queuePriority and re-sort the queue if it changes.

Larry Campbell <lcampbel>
Mon 16 May 2016 07:57:04 AM UTC, comment #1:

> You really only need to sort the queue after inserting something into it.


This would seem to assume that operation priorities cannot change once the operation is queued ; but NSOperation has -setQueuePriority: (or a queuePriority property), so that's apparently not the case.
Maybe the OSX behavior is to ignore changes in operation priority once the operation is queued?
Please could you provide a testcase demonstrating OSX behavior?

Or perhaps we could implement a patch which rather than sorting the queue, would;
a. insert to the correct position in a sorted queue and
b. on change of priority, remove and re-insert an operation.
To do the latter, I guess the queue might need to use KVO to monitor the status of the object's queuePriority while it's no the queue.

Of course, that seems rather messy/complex, so if OSX actually ignores the operation priority once the operation is queued, it would make sense to keep things simple and do the same.

Richard Frith-Macdonald <CaS>
Project Member
Sun 15 May 2016 08:53:00 PM UTC, original submission:

NSOperationQueue sorts the waiting queue every time it goes to pull an operation off the queue. If the queue is large, this is very costly, and caused huge slowdowns in an application of mine that routinely puts thousands of operations into the queue.

You really only need to sort the queue after inserting something into it.

Patch attached.

Larry Campbell <lcampbel>

 

Attached Files
file #37164:  NSOperation.m.patch added by lcampbel (875B - application/octet-stream - Patch for NSOperation.m)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by lcampbel (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 18 Jul 2016 10:16:54 AM UTCCaSStatusNeed Info=>Fixed
      Open/ClosedOpen=>In Test
    Mon 16 May 2016 07:57:04 AM UTCCaSStatusNone=>Need Info
    Sun 15 May 2016 08:53:00 PM UTClcampbelAttached File-=>Added NSOperation.m.patch, #37164

    Back to the top


    Powered by Savane 3.1-cleanup1