aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats_solver.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-12 20:49:38 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-12 20:49:38 +0000
commit3e4174aa514058d30647190e44f3dc2e39827dba (patch)
tree0abb1427e9f5290fe2bc0311f7552a34bedbb296 /src/ats/perf_ats_solver.c
parent72f0b708d9e177fe54d10c0414db77c9578aa5cd (diff)
downloadgnunet-3e4174aa514058d30647190e44f3dc2e39827dba.tar.gz
gnunet-3e4174aa514058d30647190e44f3dc2e39827dba.zip
logging update times
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r--src/ats/perf_ats_solver.c176
1 files changed, 106 insertions, 70 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index 3f0c3e49d..6504172d9 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -162,6 +162,7 @@ struct Iteration
162{ 162{
163 struct Result **results_array; 163 struct Result **results_array;
164 164
165 struct Result **update_results_array;
165}; 166};
166 167
167 168
@@ -208,24 +209,24 @@ struct Result
208 /** 209 /**
209 * Duration of setting up the problem in the solver 210 * Duration of setting up the problem in the solver
210 */ 211 */
211 struct GNUNET_TIME_Relative d_setup; 212 struct GNUNET_TIME_Relative d_setup_full;
212 213
213 /** 214 /**
214 * Duration of solving the LP problem in the solver 215 * Duration of solving the LP problem in the solver
215 * MLP solver only 216 * MLP solver only
216 */ 217 */
217 struct GNUNET_TIME_Relative d_lp; 218 struct GNUNET_TIME_Relative d_lp_full;
218 219
219 /** 220 /**
220 * Duration of solving the MLP problem in the solver 221 * Duration of solving the MLP problem in the solver
221 * MLP solver only 222 * MLP solver only
222 */ 223 */
223 struct GNUNET_TIME_Relative d_mlp; 224 struct GNUNET_TIME_Relative d_mlp_full;
224 225
225 /** 226 /**
226 * Duration of solving whole problem in the solver 227 * Duration of solving whole problem in the solver
227 */ 228 */
228 struct GNUNET_TIME_Relative d_total; 229 struct GNUNET_TIME_Relative d_total_full;
229 230
230 /** 231 /**
231 * Start time of setting up the problem in the solver 232 * Start time of setting up the problem in the solver
@@ -580,20 +581,28 @@ solver_info_cb (void *cls,
580 581
581 if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result)) 582 if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result))
582 { 583 {
583 /* Create new result */
584 tmp = GNUNET_new (struct Result); 584 tmp = GNUNET_new (struct Result);
585 ph.current_result = tmp; 585 /* Create new result */
586 ph.iterations_results[ph.current_iteration-1].results_array[ph.current_p] = tmp; 586 if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update))
587 /* 587 {
588 GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head, 588 ph.current_result = tmp;
589 ph.iterations_results[ph.current_iteration-1].result_tail, tmp);*/ 589 //fprintf (stderr,"UPDATE %u %u\n",ph.current_iteration-1, ph.current_p);
590 ph.iterations_results[ph.current_iteration-1].update_results_array[ph.current_p] = tmp;
591 }
592 else
593 {
594 ph.current_result = tmp;
595 //fprintf (stderr,"FULL %u %u\n",ph.current_iteration-1, ph.current_p);
596 ph.iterations_results[ph.current_iteration-1].results_array[ph.current_p] = tmp;
597 }
598
590 ph.current_result->addresses = ph.current_a; 599 ph.current_result->addresses = ph.current_a;
591 ph.current_result->peers = ph.current_p; 600 ph.current_result->peers = ph.current_p;
592 ph.current_result->s_total = GNUNET_TIME_absolute_get(); 601 ph.current_result->s_total = GNUNET_TIME_absolute_get();
593 ph.current_result->d_total = GNUNET_TIME_UNIT_FOREVER_REL; 602 ph.current_result->d_total_full = GNUNET_TIME_UNIT_FOREVER_REL;
594 ph.current_result->d_setup = GNUNET_TIME_UNIT_FOREVER_REL; 603 ph.current_result->d_setup_full = GNUNET_TIME_UNIT_FOREVER_REL;
595 ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL; 604 ph.current_result->d_lp_full = GNUNET_TIME_UNIT_FOREVER_REL;
596 ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL; 605 ph.current_result->d_mlp_full = GNUNET_TIME_UNIT_FOREVER_REL;
597 ph.current_result->info = add; 606 ph.current_result->info = add;
598 if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update)) 607 if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update))
599 { 608 {
@@ -608,7 +617,7 @@ solver_info_cb (void *cls,
608 return; 617 return;
609 case GAS_OP_SOLVE_STOP: 618 case GAS_OP_SOLVE_STOP:
610 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 619 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
611 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP", 620 "Solver notifies `%s' with result `%s', `%s'\n", "GAS_OP_SOLVE_STOP",
612 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); 621 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
613 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result)) 622 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
614 { 623 {
@@ -626,7 +635,7 @@ solver_info_cb (void *cls,
626 { 635 {
627 /* Finalize result */ 636 /* Finalize result */
628 ph.current_result->e_total = GNUNET_TIME_absolute_get (); 637 ph.current_result->e_total = GNUNET_TIME_absolute_get ();
629 ph.current_result->d_total = GNUNET_TIME_absolute_get_difference ( 638 ph.current_result->d_total_full = GNUNET_TIME_absolute_get_difference (
630 ph.current_result->s_total, ph.current_result->e_total); 639 ph.current_result->s_total, ph.current_result->e_total);
631 } 640 }
632 ph.current_result = NULL; 641 ph.current_result = NULL;
@@ -666,7 +675,7 @@ solver_info_cb (void *cls,
666 ph.current_result->valid = GNUNET_NO; 675 ph.current_result->valid = GNUNET_NO;
667 676
668 ph.current_result->e_setup = GNUNET_TIME_absolute_get (); 677 ph.current_result->e_setup = GNUNET_TIME_absolute_get ();
669 ph.current_result->d_setup = GNUNET_TIME_absolute_get_difference ( 678 ph.current_result->d_setup_full = GNUNET_TIME_absolute_get_difference (
670 ph.current_result->s_setup, ph.current_result->e_setup); 679 ph.current_result->s_setup, ph.current_result->e_setup);
671 return; 680 return;
672 681
@@ -703,7 +712,7 @@ solver_info_cb (void *cls,
703 ph.current_result->valid = GNUNET_NO; 712 ph.current_result->valid = GNUNET_NO;
704 713
705 ph.current_result->e_lp = GNUNET_TIME_absolute_get (); 714 ph.current_result->e_lp = GNUNET_TIME_absolute_get ();
706 ph.current_result->d_lp = GNUNET_TIME_absolute_get_difference ( 715 ph.current_result->d_lp_full = GNUNET_TIME_absolute_get_difference (
707 ph.current_result->s_lp, ph.current_result->e_lp); 716 ph.current_result->s_lp, ph.current_result->e_lp);
708 return; 717 return;
709 718
@@ -740,7 +749,7 @@ solver_info_cb (void *cls,
740 ph.current_result->valid = GNUNET_NO; 749 ph.current_result->valid = GNUNET_NO;
741 750
742 ph.current_result->e_mlp = GNUNET_TIME_absolute_get (); 751 ph.current_result->e_mlp = GNUNET_TIME_absolute_get ();
743 ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference ( 752 ph.current_result->d_mlp_full = GNUNET_TIME_absolute_get_difference (
744 ph.current_result->s_mlp, ph.current_result->e_mlp); 753 ph.current_result->s_mlp, ph.current_result->e_mlp);
745 return; 754 return;
746 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: 755 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
@@ -795,42 +804,42 @@ evaluate (int iteration)
795 } 804 }
796 805
797 806
798 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) 807 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total_full.rel_value_us)
799 { 808 {
800 fprintf (stderr, 809 fprintf (stderr,
801 "Total time to solve %s for %u peers %u addresses: %llu us\n", 810 "Total time to solve %s for %u peers %u addresses: %llu us\n",
802 (GNUNET_YES == cur->update) ? "updated" : "full", 811 (GNUNET_YES == cur->update) ? "updated" : "full",
803 cur->peers, cur->addresses, 812 cur->peers, cur->addresses,
804 (unsigned long long) cur->d_total.rel_value_us); 813 (unsigned long long) cur->d_total_full.rel_value_us);
805 } 814 }
806 815
807 816
808 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) 817 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup_full.rel_value_us)
809 { 818 {
810 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 819 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
811 "Total time to setup %s %u peers %u addresses: %llu us\n", 820 "Total time to setup %s %u peers %u addresses: %llu us\n",
812 (GNUNET_YES == cur->update) ? "updated" : "full", 821 (GNUNET_YES == cur->update) ? "updated" : "full",
813 cur->peers, cur->addresses, 822 cur->peers, cur->addresses,
814 (unsigned long long) cur->d_setup.rel_value_us); 823 (unsigned long long) cur->d_setup_full.rel_value_us);
815 } 824 }
816 825
817 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) 826 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp_full.rel_value_us)
818 { 827 {
819 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 828 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
820 "Total time to solve %s LP for %u peers %u addresses: %llu us\n", 829 "Total time to solve %s LP for %u peers %u addresses: %llu us\n",
821 (GNUNET_YES == cur->update) ? "updated" : "full", 830 (GNUNET_YES == cur->update) ? "updated" : "full",
822 cur->peers, 831 cur->peers,
823 cur->addresses, 832 cur->addresses,
824 (unsigned long long )cur->d_lp.rel_value_us); 833 (unsigned long long )cur->d_lp_full.rel_value_us);
825 } 834 }
826 835
827 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) 836 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp_full.rel_value_us)
828 { 837 {
829 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 838 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
830 "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", 839 "Total time to solve %s MLP for %u peers %u addresses: %llu us\n",
831 (GNUNET_YES == cur->update) ? "updated" : "full", 840 (GNUNET_YES == cur->update) ? "updated" : "full",
832 cur->peers, cur->addresses, 841 cur->peers, cur->addresses,
833 (unsigned long long )cur->d_mlp.rel_value_us); 842 (unsigned long long )cur->d_mlp_full.rel_value_us);
834 } 843 }
835 } 844 }
836 845
@@ -850,57 +859,48 @@ write_all_iterations (void)
850 char * data_fn_full; 859 char * data_fn_full;
851 char * data_fn_update; 860 char * data_fn_update;
852 char * data; 861 char * data;
853/* 862
854 char * str_d_total;
855 char * str_d_setup;
856 char * str_d_lp;
857 char * str_d_mlp;
858*/
859 f_full = NULL; 863 f_full = NULL;
860 f_update = NULL; 864 f_update = NULL;
861 865
862 data_fn_full = NULL; 866 data_fn_full = NULL;
863 867
864 if (ph.create_datafile) 868 if (GNUNET_NO == ph.create_datafile)
869 return;
870
871 GNUNET_asprintf (&data_fn_full,
872 "perf_%s_full_%u-%u_%u_%u.data",
873 ph.ats_string,
874 ph.total_iterations,
875 ph.N_peers_start,
876 ph.N_peers_end,
877 ph.N_address);
878 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
879 "Using data file `%s'\n",
880 data_fn_full);
881
882 f_full = GNUNET_DISK_file_open (data_fn_full,
883 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
884 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
885 if (NULL == f_full)
865 { 886 {
866 GNUNET_asprintf (&data_fn_full,
867 "perf_%s_full_avg_%u-%u_%u_%u.data",
868 ph.ats_string,
869 ph.total_iterations,
870 ph.N_peers_start,
871 ph.N_peers_end,
872 ph.N_address);
873 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 887 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
874 "Using data file `%s'\n", 888 "Cannot open data file `%s'\n",
875 data_fn_full); 889 data_fn_full);
890 GNUNET_free (data_fn_full);
891 return;
892 }
876 893
877 f_full = GNUNET_DISK_file_open (data_fn_full, 894 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
878 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 895 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
879 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
880 if (NULL == f_full)
881 {
882 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
883 "Cannot open data file `%s'\n",
884 data_fn_full);
885 GNUNET_free (data_fn_full);
886 return;
887 }
888
889 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 896 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
890 "Using update data file `%s'\n", 897 "Cannot write data to log file `%s'\n",
891 data_fn_full); 898 data_fn_full);
892 899
893 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
894 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
895 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
896 "Cannot write data to log file `%s'\n",
897 data_fn_full);
898 }
899
900 data_fn_update = NULL; 900 data_fn_update = NULL;
901 if ((ph.create_datafile) && (GNUNET_YES == ph.measure_updates)) 901 if (GNUNET_YES == ph.measure_updates)
902 { 902 {
903 GNUNET_asprintf (&data_fn_update, "perf_%s_update_avg_%u-%u_%u_%u.data", 903 GNUNET_asprintf (&data_fn_update, "perf_%s_update_%u-%u_%u_%u.data",
904 ph.ats_string, 904 ph.ats_string,
905 ph.total_iterations, 905 ph.total_iterations,
906 ph.N_peers_start, 906 ph.N_peers_start,
@@ -935,24 +935,42 @@ write_all_iterations (void)
935 { 935 {
936 char * data_str; 936 char * data_str;
937 char * data_tmp; 937 char * data_tmp;
938 char * data_upd_str;
939 char * data_upd_tmp;
938 GNUNET_asprintf(&data_str, "%u;%u",c_peer, ph.N_address); 940 GNUNET_asprintf(&data_str, "%u;%u",c_peer, ph.N_address);
941 if (ph.measure_updates)
942 GNUNET_asprintf(&data_upd_str, "%u;%u",c_peer, ph.N_address);
939 for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration ++) 943 for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration ++)
940 { 944 {
941 struct Result *cur_res; 945 struct Result *cur_full_res;
946 struct Result *cur_upd_res;
947
948
942 949
943 //fprintf (stderr, "P: %u I: %u == %p \n", c_peer, c_iteration, cur_res); 950 //fprintf (stderr, "P: %u I: %u == %p \n", c_peer, c_iteration, cur_res);
944 cur_res = ph.iterations_results[c_iteration].results_array[c_peer]; 951 cur_full_res = ph.iterations_results[c_iteration].results_array[c_peer];
945 if (c_peer == 0) 952 if (c_peer == 0)
946 continue; 953 continue;
947 if (NULL == cur_res) 954 if (NULL == cur_full_res)
948 continue; 955 continue;
949 956
957 if (ph.measure_updates)
958 {
959 cur_upd_res = ph.iterations_results[c_iteration].update_results_array[c_peer];
960 data_upd_tmp = GNUNET_strdup (data_upd_str);
961 GNUNET_free (data_upd_str);
962 GNUNET_asprintf (&data_upd_str, "%s;%llu", data_upd_tmp,
963 (NULL == cur_upd_res) ? 0 : cur_upd_res->d_total_full.rel_value_us);
964 GNUNET_free (data_upd_tmp);
965
966 }
967
950 //fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses); 968 //fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses);
951 //fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us); 969 //fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us);
952 970
953 data_tmp = GNUNET_strdup (data_str); 971 data_tmp = GNUNET_strdup (data_str);
954 GNUNET_free (data_str); 972 GNUNET_free (data_str);
955 GNUNET_asprintf (&data_str, "%s;%llu", data_tmp, cur_res->d_total.rel_value_us); 973 GNUNET_asprintf (&data_str, "%s;%llu", data_tmp, cur_full_res->d_total_full.rel_value_us);
956 GNUNET_free (data_tmp); 974 GNUNET_free (data_tmp);
957 } 975 }
958 data_tmp = GNUNET_strdup (data_str); 976 data_tmp = GNUNET_strdup (data_str);
@@ -960,10 +978,23 @@ write_all_iterations (void)
960 GNUNET_asprintf (&data_str, "%s\n", data_tmp); 978 GNUNET_asprintf (&data_str, "%s\n", data_tmp);
961 GNUNET_free (data_tmp); 979 GNUNET_free (data_tmp);
962 980
963 fprintf (stderr, "Result: %s\n", data_str); 981 fprintf (stderr, "Result full solution: %s\n", data_str);
964 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data_str, strlen(data_str))) 982 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data_str, strlen(data_str)))
965 GNUNET_break (0); 983 GNUNET_break (0);
966 GNUNET_free (data_str); 984 GNUNET_free (data_str);
985
986 if (ph.measure_updates)
987 {
988 data_upd_tmp = GNUNET_strdup (data_upd_str);
989 GNUNET_free (data_upd_str);
990 GNUNET_asprintf (&data_upd_str, "%s\n", data_upd_tmp);
991 GNUNET_free (data_upd_tmp);
992
993 fprintf (stderr, "Result updated solution: %s\n", data_upd_str);
994 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data_upd_str, strlen(data_upd_str)))
995 GNUNET_break (0);
996 GNUNET_free (data_upd_str);
997 }
967 } 998 }
968 999
969 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full))) 1000 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
@@ -994,6 +1025,8 @@ perf_run_iteration (void)
994 uint32_t net; 1025 uint32_t net;
995 1026
996 ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p + 1) * sizeof (struct Result *)); 1027 ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p + 1) * sizeof (struct Result *));
1028 if (ph.measure_updates)
1029 ph.iterations_results[ph.current_iteration-1].update_results_array = GNUNET_malloc ((count_p + 1) * sizeof (struct Result *));
997 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); 1030 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
998 for (cp = 0; cp < count_p; cp++) 1031 for (cp = 0; cp < count_p; cp++)
999 perf_create_peer (cp); 1032 perf_create_peer (cp);
@@ -1263,10 +1296,13 @@ run (void *cls, char * const *args, const char *cfgfile,
1263 { 1296 {
1264 if (0 == c2) 1297 if (0 == c2)
1265 continue; 1298 continue;
1299 if (ph.measure_updates)
1300 GNUNET_free_non_null (ph.iterations_results[c].update_results_array[c2]);
1266 GNUNET_free (ph.iterations_results[c].results_array[c2]); 1301 GNUNET_free (ph.iterations_results[c].results_array[c2]);
1267 } 1302 }
1303 if (ph.measure_updates)
1304 GNUNET_free (ph.iterations_results[c].update_results_array);
1268 GNUNET_free(ph.iterations_results[c].results_array); 1305 GNUNET_free(ph.iterations_results[c].results_array);
1269
1270 } 1306 }
1271 GNUNET_free (ph.iterations_results); 1307 GNUNET_free (ph.iterations_results);
1272 1308