[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...
From: |
mldonkey-commits |
Subject: |
[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co... |
Date: |
Tue, 30 May 2006 11:41:12 +0000 |
CVSROOT: /sources/mldonkey
Module name: mldonkey
Branch:
Changes by: spiralvoice <address@hidden> 06/05/30 11:41:12
Modified files:
distrib : ChangeLog
src/daemon/common: commonOptions.ml commonSwarming.ml
Log message:
patch #5141
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/distrib/ChangeLog.diff?tr1=1.859&tr2=1.860&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonOptions.ml.diff?tr1=1.146&tr2=1.147&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonSwarming.ml.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
Patches:
Index: mldonkey/distrib/ChangeLog
diff -u mldonkey/distrib/ChangeLog:1.859 mldonkey/distrib/ChangeLog:1.860
--- mldonkey/distrib/ChangeLog:1.859 Tue May 30 11:23:48 2006
+++ mldonkey/distrib/ChangeLog Tue May 30 11:41:12 2006
@@ -15,6 +15,12 @@
=========
2006/05/30
+5141: Swarmer: New option swarming_block_selection_algorithm (pango)
+* Allow to choose swarmer block selection algorithm at runtime.
+ - Algorithm 1 is the current default algorithm
+ - Algorithm 2, from WIP3o patch, should try harder to complete partially
+ downloaded chunks, specially with Bittorrent. It was previously
+ reverted because of unknown performance problem (slower download ?)
5140: Update .cvsignore files (pango)
5138: Catch ip banned exception (zet)
5137: HTML: Fix display of file magic values with '
Index: mldonkey/src/daemon/common/commonOptions.ml
diff -u mldonkey/src/daemon/common/commonOptions.ml:1.146
mldonkey/src/daemon/common/commonOptions.ml:1.147
--- mldonkey/src/daemon/common/commonOptions.ml:1.146 Thu May 25 20:03:10 2006
+++ mldonkey/src/daemon/common/commonOptions.ml Tue May 30 11:41:12 2006
@@ -1021,6 +1021,11 @@
"How many sources to use to download each chunk"
int_option 3
+let swarming_block_selection_algorithm =
+ define_expert_option current_section ["swarming_block_selection_algorithm"]
+ "What algorithm to use to select blocks (currently 1 or 2)"
+ int_option 1
+
(*
let delete_original = define_option current_section ["delete_original"]
"Should MLdonkey delete the file downloaded when splitting has been
succesful"
@@ -1662,6 +1667,11 @@
close_log ()
end
);
+ option_hook swarming_block_selection_algorithm (fun _ ->
+ match !!swarming_block_selection_algorithm with
+ | 1 | 2 -> ()
+ | _ -> swarming_block_selection_algorithm =:= 1;
+ );
option_hook max_upload_slots (fun _ ->
if !!max_upload_slots < 3 then
max_upload_slots =:= 3);
Index: mldonkey/src/daemon/common/commonSwarming.ml
diff -u mldonkey/src/daemon/common/commonSwarming.ml:1.34
mldonkey/src/daemon/common/commonSwarming.ml:1.35
--- mldonkey/src/daemon/common/commonSwarming.ml:1.34 Thu May 25 19:47:24 2006
+++ mldonkey/src/daemon/common/commonSwarming.ml Tue May 30 11:41:12 2006
@@ -1887,7 +1887,8 @@
choice_user_priority : int;
choice_nuploaders : int;
choice_remaining : int64;
- choice_remaining_per_uploader : int64;
+ choice_remaining_per_uploader : int64; (* algo 1 only *)
+ choice_saturated : bool; (* has enough uploades *) (* algo 2 only *)
choice_other_complete : int Lazy.t; (* ...blocks in the same chunk *)
choice_availability : int;
}
@@ -1897,7 +1898,8 @@
choice_user_priority = 0;
choice_nuploaders = 0;
choice_remaining = 0L;
- choice_remaining_per_uploader = 0L;
+ choice_remaining_per_uploader = 0L; (* algo 1 only *)
+ choice_saturated = true; (* algo 2 only *)
choice_other_complete = lazy 0;
choice_availability = 0
}
@@ -1971,11 +1973,14 @@
(* sources_per_chunk was initially for edonkey only *)
let data_per_source = 9728000L // (Int64.of_int !!sources_per_chunk) in
- let need_to_complete_some_blocks_quickly = true
- (* verification_available && t.t_nverified_chunks < 2 *) in
+ let need_to_complete_some_blocks_quickly =
+ match !!swarming_block_selection_algorithm with
+ | 1 -> true
+ | 2 -> verification_available && t.t_nverified_chunks < 2
+ | _ -> assert false in
(** > 0 == c1 is best, < 0 = c2 is best, 0 == they're equivalent *)
- let compare_choices c1 c2 =
+ let compare_choices1 c1 c2 =
(* avoid overly unbalanced situations *)
let cmp =
@@ -2037,6 +2042,90 @@
0
end in
+ let compare_choices2 c1 c2 =
+
+ (* avoid overly unbalanced situations *)
+ let cmp =
+ match c1.choice_saturated, c2.choice_saturated with
+ | false, false -> 0
+ | true, false -> -1
+ | false, true -> 1
+ | true, true ->
+ let result =
+ (* both are saturated, try to balance situation *)
+ incr delta_needed;
+ let delta =
+ c1.choice_remaining ** Int64.of_int c2.choice_nuploaders --
+ c2.choice_remaining ** Int64.of_int c1.choice_nuploaders in
+ if delta > c2.choice_remaining then 1
+ else if delta < Int64.neg c1.choice_remaining then -1
+ else begin
+ (* either way we'll unbalance the situation *)
+ incr delta_undecided;
+ 0
+ end in
+ lprintf_nl "compare_choices needed delta %d times, which
couldn't decide %d times" !delta_needed !delta_undecided;
+ result in
+ if cmp <> 0 then begin
+ incr compare_choices_saturation;
+ cmp
+ end else
+
+ (* Do what Master asked for *)
+ let cmp = compare c1.choice_user_priority c2.choice_user_priority in
+ if cmp <> 0 then begin
+ incr compare_choices_priority;
+ cmp
+ end else
+
+ (* Pick really rare gems: if average availability of all
+ blocks is higher than 5 connected sources, pick in
+ priority blocks present in at most 3 connected sources;
+ is that too restrictive ? *)
+ let cmp =
+ if not need_to_complete_some_blocks_quickly &&
+ mean_availability > 5 &&
+ (c1.choice_availability <= 3 || c2.choice_availability <= 3) then
+ compare c2.choice_availability c1.choice_availability
+ else 0 in
+ if cmp <> 0 then begin
+ incr compare_choices_rarity;
+ cmp
+ end else
+
+ (* try to quickly complete blocks *)
+ let cmp =
+ compare c2.choice_remaining c1.choice_remaining in
+ if cmp <> 0 then begin
+ incr compare_choices_completion;
+ cmp
+ end else
+
+ (* try to quickly complete (and validate) chunks;
+ if there's only one frontend, each chunk has only one
+ block, and looking at siblings make no sense *)
+ let cmp =
+ if verification_available && several_frontends then
+ compare (Lazy.force c1.choice_other_complete)
+ (Lazy.force c2.choice_other_complete)
+ else 0 in
+ if cmp <> 0 then begin
+ incr compare_choices_siblings;
+ cmp
+ end else
+
+ begin
+ (* Can't tell *)
+ incr compare_choices_failure;
+ 0
+ end in
+
+ let compare_choices =
+ match !!swarming_block_selection_algorithm with
+ | 1 -> compare_choices1
+ | 2 -> compare_choices2
+ | _ -> assert false in
+
let best_choices, specimen =
subarray_fold_lefti (fun ((best_choices, specimen) as acc) n b ->
(* priority bitmap <> 0 here ? *)
@@ -2057,8 +2146,22 @@
if block_end > preview_end then 2 else 1;
choice_nuploaders = nuploaders;
choice_remaining = remaining;
- choice_remaining_per_uploader = remaining //
- (Int64.of_int (nuploaders + 1)); (* planned value *)
+ choice_remaining_per_uploader =
+ if !!swarming_block_selection_algorithm = 1 then
+ remaining //
+ (Int64.of_int (nuploaders + 1)) (* planned value *)
+ else 0L;
+ choice_saturated =
+ if !!swarming_block_selection_algorithm = 2 then
+ not need_to_complete_some_blocks_quickly &&
+ remaining <= Int64.of_int nuploaders ** data_per_source
+ (*
+ nuploaders >= Int64.to_int (
+ Int64.pred (
+ remaining ** Int64.of_int !!sources_per_chunk ++ size)
+ // size)
+ *)
+ else true;
choice_other_complete = completed_blocks_in_chunk.(nchunk);
choice_availability = s.s_availability.(b);
} in
@@ -2084,12 +2187,13 @@
!compare_choices_rarity !compare_choices_completion
!compare_choices_siblings !compare_choices_failure;
let print_choice c =
- lprintf_nl "selected %d:%d priority:%d nup:%d rem:%Ld rpu:%Ld
sib:%s av:%d"
+ lprintf_nl "selected %d:%d priority:%d nup:%d rem:%Ld rpu:%Ld
sat:%B sib:%s av:%d"
c.choice_num up.up_complete_blocks.(c.choice_num)
c.choice_user_priority
c.choice_nuploaders
c.choice_remaining
c.choice_remaining_per_uploader
+ c.choice_saturated
(if Lazy.lazy_is_val c.choice_other_complete then
string_of_int (Lazy.force c.choice_other_complete) else "?")
c.choice_availability in
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., (continued)
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/17
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/18
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/19
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/21
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/23
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/25
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/25
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/25
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/30
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...,
mldonkey-commits <=
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/31
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/31
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/31
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/31
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/05/31