Ticket #1127: homeless_shares_in_a_set.dpatch_v2.txt

File homeless_shares_in_a_set.dpatch_v2.txt, 5.8 KB (added by zooko, at 2010-08-02T06:42:37Z)
Line 
11 patch for repository zooko@dev.allmydata.org:/home/darcs/tahoe-lafs/trunk:
2
3Mon Aug  2 00:20:04 MDT 2010  zooko@zooko.com
4  * immutable: tidy-up some code by using a set instead of list to hold homeless_shares
5
6New patches:
7
8[immutable: tidy-up some code by using a set instead of list to hold homeless_shares
9zooko@zooko.com**20100802062004
10 Ignore-this: a70bda3cf6c48ab0f0688756b015cf8d
11] {
12hunk ./src/allmydata/immutable/upload.py 190
13         self.servers_of_happiness = servers_of_happiness
14         self.needed_shares = needed_shares
15 
16-        self.homeless_shares = range(total_shares)
17+        self.homeless_shares = set(range(total_shares))
18         self.contacted_peers = [] # peers worth asking again
19         self.contacted_peers2 = [] # peers that we have asked again
20         self._started_second_pass = False
21hunk ./src/allmydata/immutable/upload.py 300
22                     level=log.NOISY, parent=self._log_parent)
23             for bucket in buckets:
24                 self.preexisting_shares.setdefault(bucket, set()).add(peer)
25-                if self.homeless_shares and bucket in self.homeless_shares:
26-                    self.homeless_shares.remove(bucket)
27+                self.homeless_shares.discard(bucket)
28             self.full_count += 1
29             self.bad_query_count += 1
30 
31hunk ./src/allmydata/immutable/upload.py 361
32                         server, sharelist = items.pop()
33                         if len(sharelist) > 1:
34                             share = sharelist.pop()
35-                            self.homeless_shares.append(share)
36+                            self.homeless_shares.add(share)
37                             self.preexisting_shares[share].remove(server)
38                             if not self.preexisting_shares[share]:
39                                 del self.preexisting_shares[share]
40hunk ./src/allmydata/immutable/upload.py 385
41             # TODO: don't pre-convert all peerids to PeerTrackers
42             assert isinstance(peer, PeerTracker)
43 
44-            shares_to_ask = set([self.homeless_shares.pop(0)])
45+            shares_to_ask = set(sorted(self.homeless_shares)[:1])
46+            self.homeless_shares -= shares_to_ask
47             self.query_count += 1
48             self.num_peers_contacted += 1
49             if self._status:
50hunk ./src/allmydata/immutable/upload.py 407
51             num_shares = mathutil.div_ceil(len(self.homeless_shares),
52                                            len(self.contacted_peers))
53             peer = self.contacted_peers.pop(0)
54-            shares_to_ask = set(self.homeless_shares[:num_shares])
55-            self.homeless_shares[:num_shares] = []
56+            shares_to_ask = set(sorted(self.homeless_shares)[:num_shares])
57+            self.homeless_shares -= shares_to_ask
58             self.query_count += 1
59             if self._status:
60                 self._status.set_status("Contacting Peers [%s] (second query),"
61hunk ./src/allmydata/immutable/upload.py 455
62                     level=log.UNUSUAL, parent=self._log_parent)
63             self.error_count += 1
64             self.bad_query_count += 1
65-            self.homeless_shares = list(shares_to_ask) + self.homeless_shares
66+            self.homeless_shares |= shares_to_ask
67             if (self.uncontacted_peers
68                 or self.contacted_peers
69                 or self.contacted_peers2):
70hunk ./src/allmydata/immutable/upload.py 516
71 
72                 # some shares are still homeless, keep trying to find them a
73                 # home. The ones that were rejected get first priority.
74-                self.homeless_shares = (list(still_homeless)
75-                                        + self.homeless_shares)
76+                self.homeless_shares |= still_homeless
77                 # Since they were unable to accept all of our requests, so it
78                 # is safe to assume that asking them again won't help.
79             else:
80}
81
82Context:
83
84[docs: add Jacob Lyles to CREDITS
85zooko@zooko.com**20100730230500
86 Ignore-this: 9dbbd6a591b4b1a5a8dcb69b7b757792
87]
88[web: don't use %d formatting on a potentially large negative float -- there is a bug in Python 2.5 in that case
89jacob.lyles@gmail.com**20100730220550
90 Ignore-this: 7080eb4bddbcce29cba5447f8f4872ee
91 fixes #1055
92]
93[docs: fix licensing typo that was earlier fixed in [20090921164651-92b7f-7f97b58101d93dc588445c52a9aaa56a2c7ae336]
94zooko@zooko.com**20100729052923
95 Ignore-this: a975d79115911688e5469d4d869e1664
96 I wish we didn't copies of this licensing text in several different files so that changes can be accidentally omitted from some of them.
97]
98[misc/build_helpers/run-with-pythonpath.py: fix stale comment, and remove 'trial' example that is not the right way to run trial.
99david-sarah@jacaranda.org**20100726225729
100 Ignore-this: a61f55557ad69a1633bfb2b8172cce97
101]
102[docs/specifications/dirnodes.txt: 'mesh'->'grid'.
103david-sarah@jacaranda.org**20100723061616
104 Ignore-this: 887bcf921ef00afba8e05e9239035bca
105]
106[docs/specifications/dirnodes.txt: bring layer terminology up-to-date with architecture.txt, and a few other updates (e.g. note that the MAC is no longer verified, and that URIs can be unknown). Also 'Tahoe'->'Tahoe-LAFS'.
107david-sarah@jacaranda.org**20100723054703
108 Ignore-this: f3b98183e7d0a0f391225b8b93ac6c37
109]
110[__init__.py: silence DeprecationWarning about BaseException.message globally. fixes #1129
111david-sarah@jacaranda.org**20100720011939
112 Ignore-this: 38808986ba79cb2786b010504a22f89
113]
114[test_runner: test that 'tahoe --version' outputs no noise (e.g. DeprecationWarnings).
115david-sarah@jacaranda.org**20100720011345
116 Ignore-this: dd358b7b2e5d57282cbe133e8069702e
117]
118[docs: use current cap to Zooko's wiki page in example text
119zooko@zooko.com**20100721010543
120 Ignore-this: 4f36f36758f9fdbaf9eb73eac23b6652
121 fixes #1134
122]
123[TAG allmydata-tahoe-1.7.1
124zooko@zooko.com**20100719131352
125 Ignore-this: 6942056548433dc653a746703819ad8c
126]
127Patch bundle hash:
128f56a05301bf0f3319810c21e786303c5d54bac16