mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-08 19:34:18 +00:00
immutable: when downloading an immutable file, use primary shares if they are available
Primary shares require no erasure decoding so the more primary shares you have, the less CPU is used.
This commit is contained in:
parent
a71a68b31e
commit
ec86563326
@ -875,8 +875,13 @@ class FileDownloader(log.PrefixingLogMixin):
|
||||
potential_shnums = list(available_shnums - handled_shnums)
|
||||
if not potential_shnums:
|
||||
raise NotEnoughSharesError
|
||||
# choose a random share
|
||||
shnum = random.choice(potential_shnums)
|
||||
# For the next share, choose a primary share if available, else a randomly chosen
|
||||
# secondary share.
|
||||
potential_shnums.sort()
|
||||
if potential_shnums[0] < self._uri.needed_shares:
|
||||
shnum = potential_shnums[0]
|
||||
else:
|
||||
shnum = random.choice(potential_shnums)
|
||||
# and a random bucket that will provide it
|
||||
validated_bucket = random.choice(list(self._share_vbuckets[shnum]))
|
||||
self.active_buckets[shnum] = validated_bucket
|
||||
|
Loading…
x
Reference in New Issue
Block a user