mldonkey-commits
[Top][All Lists]
Advanced

[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: Sun, 04 Feb 2007 17:19:50 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       07/02/04 17:19:50

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonOptions.ml commonSwarming.ml 

Log message:
        patch #5720

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1169&r2=1.1170
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.196&r2=1.197
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonSwarming.ml?cvsroot=mldonkey&r1=1.57&r2=1.58

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1169
retrieving revision 1.1170
diff -u -b -r1.1169 -r1.1170
--- distrib/ChangeLog   30 Jan 2007 21:23:01 -0000      1.1169
+++ distrib/ChangeLog   4 Feb 2007 17:19:50 -0000       1.1170
@@ -14,6 +14,15 @@
 ChangeLog
 =========
 
+2007/02/04
+5720: Swarmer: block choice algorithm 2 from patch 5141 is new default
+- remove swarming_block_selection_algorithm = 1
+  because it finishes chunks too slowly
+- remove swarming_block_selection_algorithm = 3 from TripleM
+  because it uses too much CPU power.
+- remove option swarming_block_selection_algorithm, hard-coded default is now 2
+- remove option block_switching, hard-coded default is now true
+
 2007/01/30
 5717: Optimize function print_command_result
 

Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -b -r1.196 -r1.197
--- src/daemon/common/commonOptions.ml  25 Jan 2007 13:55:37 -0000      1.196
+++ src/daemon/common/commonOptions.ml  4 Feb 2007 17:19:50 -0000       1.197
@@ -1187,15 +1187,6 @@
   "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, 2 or 3)"
-    int_option 1
-
-let block_switching = define_expert_option current_section ["block_switching"]
-  "Allows swarmer to switch a source to another block if current block is 
already
-  totally selected by other sources"
-    bool_option true
-
 let max_recover_gap = define_option current_section ["max_recover_zeroes_gap"]
   "The maximal length of zero bytes between non-zero bytes in a file that
   should be interpreted as downloaded during a recovery"
@@ -1776,11 +1767,6 @@
           close_log ()
         end
   );
-  option_hook swarming_block_selection_algorithm (fun _ ->
-    match !!swarming_block_selection_algorithm with
-    | 1 | 2 | 3 -> ()
-    | _ -> swarming_block_selection_algorithm =:= 1;
-  );
   option_hook max_upload_slots (fun _ ->
       if !!max_upload_slots < 3 then
         max_upload_slots =:= 3);

Index: src/daemon/common/commonSwarming.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonSwarming.ml,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- src/daemon/common/commonSwarming.ml 25 Jan 2007 13:09:16 -0000      1.57
+++ src/daemon/common/commonSwarming.ml 4 Feb 2007 17:19:50 -0000       1.58
@@ -136,10 +136,6 @@
     mutable t_chunk_of_block : int array;
   }
 
-and uploader_map = {
-    mutable um_map : Bitv.t;
-    }
-
 and swarmer = {
     s_num : int;
     s_filename : string;
@@ -153,7 +149,6 @@
     mutable s_verified_bitmap : VerificationBitmap.t;
     mutable s_disk_allocated : Bitv.t;
     mutable s_availability : int array;
-    mutable s_availability_map : (client,uploader_map) Hashtbl.t;
     mutable s_nuploading : int array;
 (*    mutable s_last_seen : int array; *)
 
@@ -578,7 +573,6 @@
     s_blocks = [||];
     s_block_pos = [||];
     s_availability = [||];
-    s_availability_map = Hashtbl.create 0;
     s_nuploading = [||];
   }
 
@@ -619,7 +613,6 @@
       s_blocks = Array.create nblocks EmptyBlock ;
       s_block_pos = Array.create nblocks zero;
       s_availability = Array.create nblocks 0;
-      s_availability_map = Hashtbl.create 0;
       s_nuploading = Array.create nblocks 0;
 (*      s_last_seen = Array.create nblocks 0; *)
     }
@@ -748,7 +741,6 @@
   s.s_verified_bitmap <- VB.create nblocks VB.State_missing;
   s.s_block_pos <- Array.create nblocks zero;
   s.s_availability <- Array.create nblocks 0; (* not preserved ? *)
-  s.s_availability_map <- Hashtbl.create 1023;
   s.s_nuploading <- Array.create nblocks 0; (* not preserved ? *)
 (*  s.s_last_seen <- Array.create nblocks 0; *)
 
@@ -1719,26 +1711,15 @@
   let complete_blocks = ref [] in
   let partial_blocks = ref [] in
 
-  let uploaders_map = 
-    try
-      Hashtbl.find s.s_availability_map up.up_client
-    with Not_found ->
-      let map = {um_map = Bitv.create (Array.length s.s_blocks) false
-      } in
-      Hashtbl.add s.s_availability_map up.up_client map;
-      map
-  in
-  let map = uploaders_map.um_map in
-  (* we dont initialize the map with false for an exiting uploader,
-     cause the number of blocks should increase over time, not decrease.
-     should we? *)
+  let incr_availability s i =
+    s.s_availability.(i) <- s.s_availability.(i) + 1 in
 
   (match intervals with
    | AvailableIntervals intervals ->
        iter_intervals s (fun i block_begin block_end interval_begin 
interval_end ->
 (*              lprintf "iter_intervals %d %Ld-%Ld %Ld-%Ld\n"
                 i block_begin block_end interval_begin interval_end; *)
-         Bitv.set map i true;
+         incr_availability s i;
 
          match s.s_blocks.(i) with
         | CompleteBlock | VerifiedBlock -> ()
@@ -1753,7 +1734,7 @@
    | AvailableBitv bitmap ->
        Bitv.iteri_true (fun i ->
          List.iter (fun j ->
-           Bitv.set map j true;
+           incr_availability s j;
            complete_blocks := j :: !complete_blocks
          ) t.t_blocks_of_chunk.(i)
        ) bitmap
@@ -1765,14 +1746,6 @@
     t.t_last_seen.(i) <- BasicSocket.last_time ()
   ) !complete_blocks;
 
-  let availability = Array.create (Array.length s.s_blocks) 0 in
-  Hashtbl.iter (fun _ j ->
-    Bitv.iteri_true (fun i ->
-      availability.(i) <- availability.(i) + 1
-    ) j.um_map
-  ) s.s_availability_map;
-  s.s_availability <- availability;
-
   let complete_blocks = Array.of_list !complete_blocks in
   let partial_blocks = Array.of_list !partial_blocks in
   up.up_intervals <- intervals;
@@ -1862,8 +1835,18 @@
 
 let clear_uploader_intervals up =
   if up.up_declared then
+    let decr_availability s i =
+      if s.s_availability.(i) > 0 then
+       s.s_availability.(i) <- s.s_availability.(i) - 1 
+      else 
+       lprintf_nl "clear_uploader_intervals: some s_availability was about to 
become negative\n" in
+(*          lprintf "clean_uploader_chunks:\n"; *)
+    let t = up.up_t in
+    let s = t.t_s in
+    Array.iter (decr_availability s) up.up_complete_blocks;
     up.up_complete_blocks <- [||];
     up.up_ncomplete <- 0;
+    Array.iter (fun (b,_,_) -> decr_availability s b) up.up_partial_blocks;
     up.up_partial_blocks <- [||];
     up.up_npartial <- 0;
     clear_uploader_blocks up;
@@ -2143,11 +2126,8 @@
        let data_per_source = 9728000L // (Int64.of_int !!sources_per_chunk) in
        
        let need_to_complete_some_blocks_quickly = 
-         match !!swarming_block_selection_algorithm with
-         | 1 -> true
-         | 2 -> verification_available && t.t_nverified_chunks < 2
-         | 3 -> false
-         | _ -> assert false in
+         verification_available && t.t_nverified_chunks < 2
+        in
 
        let create_choice n b =
          let block_begin = compute_block_begin s b in
@@ -2219,66 +2199,7 @@
            (choice_availability c) 
            (choice_preallocated c) in
 
-       (** > 0 == c1 is best, < 0 = c2 is best, 0 == they're equivalent *)
-       let compare_choices1 c1 c2 =
-
-         (* avoid overly unbalanced situations *)
-         let cmp =
-           if choice_remaining_per_uploader c1 < data_per_source ||
-             choice_remaining_per_uploader c2 < data_per_source then
-               compare (choice_remaining_per_uploader c1)
-                 (choice_remaining_per_uploader c2) else 0 in
-         if cmp <> 0 then cmp else
-
-         (* Do what Master asked for *)
-         let cmp = compare (choice_user_priority c1)
-           (choice_user_priority c2) in
-         if cmp <> 0 then cmp 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 &&
-             (choice_availability c1 <= 3 || choice_availability c2 <= 3) then
-               compare (choice_availability c2) (choice_availability c1)
-           else 0 in
-         if cmp <> 0 then cmp 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 (choice_other_remaining c2)
-               (choice_other_remaining c1)
-           else 0 in
-         if cmp <> 0 then cmp else
-
-         (* try to quickly complete blocks *)
-         let cmp = 
-           match choice_unselected_remaining c1,
-           choice_unselected_remaining c2 with
-           | 0L, 0L -> 0
-           | 0L, _ -> -1
-           | _, 0L -> 1
-           | ur1, ur2 -> compare ur2 ur1 in
-         if cmp <> 0 then cmp else
-
-         (* pick blocks that won't require allocating more disk space *)
-         let cmp =
-           match choice_preallocated c1, choice_preallocated c2 with
-           | true, false -> 1
-           | false, true -> -1
-           | _ -> 0 in
-         if cmp <> 0 then cmp else
-
-           (* Can't tell *)
-           0 in
-
-       let compare_choices2 c1 c2 =
+       let compare_choices c1 c2 =
          (* "RULES" *)
          (* Avoid stepping on each other's feet *)
          let cmp =
@@ -2348,81 +2269,6 @@
            (* Can't tell *)
            0 in
 
-       let compare_choices3 c1 c2 =
-         (* "RULES" *)
-         (* Avoid stepping on each other's feet *)
-         let cmp =
-           match choice_unselected_remaining c1,
-           choice_unselected_remaining c2 with
-           | 0L, 0L -> 0
-           | _, 0L -> 1
-           | 0L, _ -> -1
-           | _, _ -> 0 in
-         if cmp <> 0 then cmp else
-
-    (* avoid overly unbalanced situations *)
-    let cmp =
-      match choice_saturated c1, choice_saturated c2 with
-      | false, false -> 0
-      | false, true -> 1
-      | true, false -> -1
-      | true, true -> 0 in
-    if cmp <> 0 then cmp else
-
-    (* "WISHES" *)
-         (* Do what Master asked for *)
-    let cmp = compare (choice_user_priority c1)
-             (choice_user_priority c2) in
-         if cmp <> 0 then cmp else
-
-    (* "OPTIMIZATIONS" *)
-    (* Allways pick rarer choice, if at least one availability
-       is below mean_availability*)
-    let cmp =
-      if not need_to_complete_some_blocks_quickly &&
-      (mean_availability < 5 ||
-      choice_availability c1 <= mean_availability || 
-      choice_availability c2 <= mean_availability) then
-        compare (choice_availability c2)
-        (choice_availability c1)
-      else 0 in
-    if cmp <> 0 then cmp 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 (choice_other_remaining c2)
-        (choice_other_remaining c1)
-           else 0 in
-         if cmp <> 0 then cmp else
-
-         (* try to quickly complete blocks *)
-         let cmp = 
-           compare (choice_unselected_remaining c2)
-             (choice_unselected_remaining c1) in
-         if cmp <> 0 then cmp else
-
-         (* pick blocks that won't require allocating more disk space *)
-         let cmp =
-           match choice_preallocated c1, choice_preallocated c2 with
-           | true, false -> 1
-           | false, true -> -1
-           | _ -> 0 in
-         if cmp <> 0 then cmp else
-
-         (* "DEFAULT" *)
-           (* Can't tell *)
-           0 in
-
-       let compare_choices =
-         match !!swarming_block_selection_algorithm with
-         | 1 -> compare_choices1
-         | 2 -> compare_choices2
-         | 3 -> compare_choices3
-         | _ -> assert false in
-
        (* compare a new chunk against a list of best choices numbers (and a
           specimen of best choice) *)
        let keep_best_chunks chunk_blocks_indexes best_choices specimen =
@@ -2469,9 +2315,7 @@
           currently they're taken care of by linear_select_block
           fallback below *)
 
-       if debug_all then begin
-         print_choice specimen
-       end;
+       if debug_all then print_choice specimen;
 
        try
          let blocks = 
@@ -2777,7 +2621,6 @@
        iter dummy_ranges_cluster b.up_block.block_ranges b more_blocks in
       if not (is_dummy_cluster best_cluster) &&
        best_cluster.cluster_nuploading > 0 &&
-       !!block_switching &&
        (file_downloaded t.t_file < file_size t.t_file ** 98L // 100L) then 
begin
        (* it seems they're only sucky choices left on that block, is
           there really nothing else better elsewhere ? *)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]