Merge lp:~vorlon/ubuntu-archive-tools/queue-item-scaling into lp:ubuntu-archive-tools

Proposed by Steve Langasek
Status: Merged
Merged at revision: 568
Proposed branch: lp:~vorlon/ubuntu-archive-tools/queue-item-scaling
Merge into: lp:ubuntu-archive-tools
Diff against target: 39 lines (+5/-4)
1 file modified
queue (+5/-4)
To merge this branch: bzr merge lp:~vorlon/ubuntu-archive-tools/queue-item-scaling
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+118166@code.launchpad.net

Description of the change

"if not item in list [...] list.append(item)" doesn't scale so good. Use a
set instead so the queue command will scale to handling the 800+ matches for
'queue accept language-pack'.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

I think this will break ordering in 'queue info'. How about using
collections.OrderedDict instead? (Or the collections documentation has
a link to a recipe for OrderedSet.)

Revision history for this message
Steve Langasek (vorlon) wrote :

On Fri, Aug 03, 2012 at 07:13:19PM -0000, Colin Watson wrote:
> I think this will break ordering in 'queue info'.

Confirmed.

> How about using collections.OrderedDict instead? (Or the collections
> documentation has a link to a recipe for OrderedSet.)

Looks like this works without too much trouble. I don't see any easy way to
test the performance currently, now that the language packs have been
flushed from the queue, but it at least seems to be working reliably.
Pushed an update.

566. By Steve Langasek

use collections.OrderedDict() instead of a set, so we can still display items in the queue in order

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'queue'
2--- queue 2012-07-18 15:32:38 +0000
3+++ queue 2012-08-03 22:02:18 +0000
4@@ -23,6 +23,7 @@
5 from operator import attrgetter
6 from optparse import OptionParser
7 import sys
8+import collections
9 try:
10 from urllib.parse import unquote, urlsplit
11 from urllib.request import urlretrieve
12@@ -71,7 +72,7 @@
13 if not args:
14 args = ['']
15
16- items = []
17+ items = collections.OrderedDict()
18 for arg in args:
19 arg = arg.strip()
20 if arg.isdigit():
21@@ -94,7 +95,7 @@
22 item_suite, options.distribution.name,
23 options.suite))
24 if queue_item_allowed(options, item):
25- items.append(item)
26+ items[item] = 1
27 else:
28 kwargs = {}
29 if "/" in arg:
30@@ -105,8 +106,8 @@
31 pocket=options.pocket, status=options.queue,
32 exact_match=options.exact_match, **kwargs)
33 for item in new_items:
34- if item not in items and queue_item_allowed(options, item):
35- items.append(item)
36+ if queue_item_allowed(options, item):
37+ items[item] = 1
38
39 return items
40

Subscribers

People subscribed via source and target branches