Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#13349 closed bug (fixed)

find function slower since 1.9.0, especially in chrome

Reported by: ktmitton@… Owned by: dmethvin
Priority: high Milestone: 1.9.1
Component: traversing Version: git
Keywords: Cc:
Blocked by: Blocking:

Description

I noticed when selecting a large array of elements (in my case 11,000+), the jQuery find function would perform much slower in 1.9.0 than in previous versions of jQuery. Looking into the code, it looks like the function was rewritten to use the jQuery.unique function, which was actually mapped to Swizzle.uniqueSort.

It turns out the actual sorting part of the function:

results.sort( sortOrder );

is where the slowdown occurs. I tested in Firefox and IE as well, and the slowdown wasn't as noticeable, but in chrome this added 5-10 seconds to the find.

I created a jsFiddle test http://jsfiddle.net/E6gPN/6/ that creates 12,000 options, runs the find, and outputs the amount of time it took to execute the find.

Change History (6)

comment:1 Changed 10 years ago by dmethvin

Status: newopen

1) In what kind of situation do you have 11,000 DOM elements?

2) Looks like it's unnecessarily going through a unique sort in .find() since for that simple case the results will already be sorted.

comment:2 in reply to:  1 Changed 10 years ago by anonymous

Replying to dmethvin:

1) In what kind of situation do you have 11,000 DOM elements?

2) Looks like it's unnecessarily going through a unique sort in .find() since for that simple case the results will already be sorted.

1) I know it sounds ridiculous, but I actually do have a few select boxes that are populated with that many options, and I'm not permitted to change that.

2) Yeah, that's what I found. If I had to guess, the unique function call probably just seemed like a nice way to trim down the original code in the function, and the sort probably seemed negligible to the person who rewrote find, and like you said doesn't really change anything.

comment:3 Changed 10 years ago by dmethvin

Component: unfiledtraversing
Milestone: None1.9.1
Owner: set to dmethvin
Priority: undecidedhigh
Status: openassigned

comment:4 Changed 10 years ago by Dave Methvin

Resolution: fixed
Status: assignedclosed

Fix #13349. No need to sort simple .find() cases.

Changeset: 1bbe2b1ded24edf7bf7b18512aff4148591803da

comment:5 Changed 10 years ago by Dave Methvin

Fix #13349. No need to sort simple .find() cases.

Changeset: a5c33fe1f7872a20267ff69905561c8cc55fe3c1

comment:6 Changed 10 years ago by nelumirea82@…

Excellent site - do keep up the good work.

Note: See TracTickets for help on using tickets.