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

Group
 
 

bug #47926: Poor performance in NSOperationQueue

Submitter:  Larry Campbell <lcampbel>
Submitted:  Sun 15 May 2016 08:53:00 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  In Test
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

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
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by lcampbel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-18 CaS StatusNeed Info Fixed
        Open/ClosedOpen In Test
    2016-05-16 CaS StatusNone Need Info
    2016-05-15 lcampbel Attached File- Added NSOperation.m.patch, #37164

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code