Closed
Bug 703788
Opened 13 years ago
Closed 13 years ago
Improve performance of diff_arrays() with large arrays
Categories
(Bugzilla :: Bugzilla-General, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 4.2
People
(Reporter: LpSolit, Assigned: LpSolit)
References
Details
(Keywords: perf)
Attachments
(1 file)
3.98 KB,
patch
|
mkanat
:
review+
|
Details | Diff | Splinter Review |
In order to fix bug 644281 and to detect changes between two buglists, which can both contain thousands of bug IDs, I need to rewrite diff_arrays() to make it work efficiently with large arrays. The difference is already noticeable with only a few items in both arrays: the improvement is 2-3x faster! With two arrays of 10,000 items each, the improvement is huge: 49 seconds (old) vs 0.03 second (new)!! And with 100,000 items, my rewrite makes diff_arrays() to complete in 0.35 second only (and probably several tens of minutes or hours with the old code)!
I included a test in t/007util.t to validate my code.
Attachment #575588 -
Flags: review?(mkanat)
Comment 1•13 years ago
|
||
Comment on attachment 575588 [details] [diff] [review]
patch, v1
Review of attachment 575588 [details] [diff] [review]:
-----------------------------------------------------------------
Awesome. Wow, what a remarkable speedup! I bet this was biting us in places we didn't even know.
::: t/007util.t
@@ +83,5 @@
> +# Removed (in this order): gamma alpha gamma.
> +# Added (in this order): delta
> +my ($removed, $added) = diff_arrays(\@old_array, \@new_array);
> +is(join(":", @$removed), 'gamma:alpha:gamma', 'diff_array(\@old, \@new) (check removal)');
> +is(join(":", @$added), 'delta', 'diff_array(\@old, \@new) (check addition)');
You can use is_deeply here instead of doing an is with a join.
Attachment #575588 -
Flags: review?(mkanat) → review+
Updated•13 years ago
|
Flags: approval4.2+
Flags: approval+
![]() |
Assignee | |
Comment 2•13 years ago
|
||
I replaced is() by is_deeply(), as suggested.
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/Util.pm
modified t/007util.t
Committed revision 8006.
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/4.2/
modified Bugzilla/Util.pm
modified t/007util.t
Committed revision 7957.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•