aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c28
-rw-r--r--src/rps/rps-test_util.h2
-rw-r--r--src/rps/test_rps.c104
3 files changed, 110 insertions, 24 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index aeb0eabc2..56c3c52b6 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -3727,14 +3727,36 @@ do_round (void *cls)
3727 } else { 3727 } else {
3728 LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n"); 3728 LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n");
3729 GNUNET_STATISTICS_update(stats, "# rounds blocked", 1, GNUNET_NO); 3729 GNUNET_STATISTICS_update(stats, "# rounds blocked", 1, GNUNET_NO);
3730 if (CustomPeerMap_size (push_map) > alpha * View_size ()) 3730 if (CustomPeerMap_size (push_map) > alpha * View_size () &&
3731 !(0 >= CustomPeerMap_size (pull_map)))
3731 GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes", 1, GNUNET_NO); 3732 GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes", 1, GNUNET_NO);
3732 if (0 >= CustomPeerMap_size (push_map)) 3733 if (CustomPeerMap_size (push_map) > alpha * View_size () &&
3734 (0 >= CustomPeerMap_size (pull_map)))
3735 GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes, no pull replies", 1, GNUNET_NO);
3736 if (0 >= CustomPeerMap_size (push_map) &&
3737 !(0 >= CustomPeerMap_size (pull_map)))
3733 GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes", 1, GNUNET_NO); 3738 GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes", 1, GNUNET_NO);
3734 if (0 >= CustomPeerMap_size (pull_map)) 3739 if (0 >= CustomPeerMap_size (push_map) &&
3740 (0 >= CustomPeerMap_size (pull_map)))
3741 GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes, no pull replies", 1, GNUNET_NO);
3742 if (0 >= CustomPeerMap_size (pull_map) &&
3743 CustomPeerMap_size (push_map) > alpha * View_size () &&
3744 0 >= CustomPeerMap_size (push_map))
3735 GNUNET_STATISTICS_update(stats, "# rounds blocked - no pull replies", 1, GNUNET_NO); 3745 GNUNET_STATISTICS_update(stats, "# rounds blocked - no pull replies", 1, GNUNET_NO);
3736 } 3746 }
3737 // TODO independent of that also get some peers from CADET_get_peers()? 3747 // TODO independent of that also get some peers from CADET_get_peers()?
3748 GNUNET_STATISTICS_set (stats,
3749 "# peers in push map at end of round",
3750 CustomPeerMap_size (push_map),
3751 GNUNET_NO);
3752 GNUNET_STATISTICS_set (stats,
3753 "# peers in pull map at end of round",
3754 CustomPeerMap_size (pull_map),
3755 GNUNET_NO);
3756 GNUNET_STATISTICS_set (stats,
3757 "# peers in view at end of round",
3758 View_size (),
3759 GNUNET_NO);
3738 3760
3739 LOG (GNUNET_ERROR_TYPE_DEBUG, 3761 LOG (GNUNET_ERROR_TYPE_DEBUG,
3740 "Received %u pushes and %u pulls last round (alpha (%.2f) * view_size (%u) = %.2f)\n", 3762 "Received %u pushes and %u pulls last round (alpha (%.2f) * view_size (%u) = %.2f)\n",
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index 209152151..225db4b1d 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -53,7 +53,7 @@ create_file (const char *name);
53 int size;\ 53 int size;\
54 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ 54 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
55 if (0 > size)\ 55 if (0 > size)\
56 LOG (GNUNET_ERROR_TYPE_WARNING,\ 56 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
57 "Failed to create tmp_buf\n");\ 57 "Failed to create tmp_buf\n");\
58 else\ 58 else\
59 to_file_(file_name,tmp_buf);\ 59 to_file_(file_name,tmp_buf);\
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index c5a2c0458..4ef97ad92 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -253,24 +253,31 @@ struct RPSPeer
253 * Used to check whether we are able to shutdown. 253 * Used to check whether we are able to shutdown.
254 */ 254 */
255 uint32_t stat_collected_flags; 255 uint32_t stat_collected_flags;
256
257 /**
258 * @brief File name of the file the stats are finally written to
259 */
260 char *file_name_stats;
256}; 261};
257 262
258enum STAT_TYPE 263enum STAT_TYPE
259{ 264{
260 STAT_TYPE_ROUNDS = 0x1, /* 1 */ 265 STAT_TYPE_ROUNDS = 0x1, /* 1 */
261 STAT_TYPE_BLOCKS = 0x2, /* 2 */ 266 STAT_TYPE_BLOCKS = 0x2, /* 2 */
262 STAT_TYPE_BLOCKS_MANY_PUSH = 0x4, /* 3 */ 267 STAT_TYPE_BLOCKS_MANY_PUSH = 0x4, /* 3 */
263 STAT_TYPE_BLOCKS_FEW_PUSH = 0x8, /* 4 */ 268 STAT_TYPE_BLOCKS_NO_PUSH = 0x8, /* 4 */
264 STAT_TYPE_BLOCKS_FEW_PULL = 0x10, /* 5 */ 269 STAT_TYPE_BLOCKS_NO_PULL = 0x10, /* 5 */
265 STAT_TYPE_ISSUED_PUSH_SEND = 0x20, /* 6 */ 270 STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL = 0x20, /* 6 */
266 STAT_TYPE_ISSUED_PULL_REQ = 0x40, /* 7 */ 271 STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL = 0x40, /* 7 */
267 STAT_TYPE_ISSUED_PULL_REP = 0x80, /* 8 */ 272 STAT_TYPE_ISSUED_PUSH_SEND = 0x80, /* 8 */
268 STAT_TYPE_SENT_PUSH_SEND = 0x100, /* 9 */ 273 STAT_TYPE_ISSUED_PULL_REQ = 0x100, /* 9 */
269 STAT_TYPE_SENT_PULL_REQ = 0x200, /* 10 */ 274 STAT_TYPE_ISSUED_PULL_REP = 0x200, /* 10 */
270 STAT_TYPE_SENT_PULL_REP = 0x400, /* 11 */ 275 STAT_TYPE_SENT_PUSH_SEND = 0x400, /* 11 */
271 STAT_TYPE_RECV_PUSH_SEND = 0x800, /* 12 */ 276 STAT_TYPE_SENT_PULL_REQ = 0x800, /* 12 */
272 STAT_TYPE_RECV_PULL_REQ = 0x1000, /* 13 */ 277 STAT_TYPE_SENT_PULL_REP = 0x1000, /* 13 */
273 STAT_TYPE_RECV_PULL_REP = 0x2000, /* 14 */ 278 STAT_TYPE_RECV_PUSH_SEND = 0x2000, /* 14 */
279 STAT_TYPE_RECV_PULL_REQ = 0x4000, /* 15 */
280 STAT_TYPE_RECV_PULL_REP = 0x8000, /* 16 */
274 STAT_TYPE_MAX = 0x80000000, /* 32 */ 281 STAT_TYPE_MAX = 0x80000000, /* 32 */
275}; 282};
276 283
@@ -1527,8 +1534,8 @@ manage_service_wrapper (unsigned int i, unsigned int j,
1527 &churn_cb, 1534 &churn_cb,
1528 entry, 1535 entry,
1529 (PEER_GO_OFFLINE == delta) ? 0 : 1); 1536 (PEER_GO_OFFLINE == delta) ? 0 : 1);
1537 rps_peers[j].entry_op_manage = entry;
1530 } 1538 }
1531 rps_peers[j].entry_op_manage = entry;
1532} 1539}
1533 1540
1534 1541
@@ -1738,6 +1745,50 @@ profiler_eval (void)
1738} 1745}
1739 1746
1740/** 1747/**
1748 * @brief Try to ensure that `/tmp/rps` exists.
1749 *
1750 * @return #GNUNET_YES on success
1751 * #GNUNET_SYSERR on failure
1752 */
1753static int ensure_folder_exist (void)
1754{
1755 if (GNUNET_NO == GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
1756 {
1757 GNUNET_DISK_directory_create ("/tmp/rps");
1758 }
1759 if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
1760 {
1761 return GNUNET_SYSERR;
1762 }
1763 return GNUNET_YES;
1764}
1765
1766static void
1767store_stats_file_name (struct RPSPeer *rps_peer)
1768{
1769 unsigned int len_file_name;
1770 unsigned int out_size;
1771 char *file_name;
1772
1773 if (GNUNET_SYSERR == ensure_folder_exist()) return;
1774 len_file_name = (14 + strlen (GNUNET_i2s_full (rps_peer->peer_id)) + 1) * sizeof (char);
1775 file_name = GNUNET_malloc (len_file_name);
1776 out_size = GNUNET_snprintf (file_name,
1777 len_file_name,
1778 "/tmp/rps/stat-%s",
1779 GNUNET_i2s_full (rps_peer->peer_id));
1780 if (len_file_name < out_size ||
1781 0 > out_size)
1782 {
1783 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1784 "Failed to write string to buffer (size: %i, out_size: %i)\n",
1785 len_file_name,
1786 out_size);
1787 }
1788 rps_peer->file_name_stats = file_name;
1789}
1790
1791/**
1741 * Continuation called by #GNUNET_STATISTICS_get() functions. 1792 * Continuation called by #GNUNET_STATISTICS_get() functions.
1742 * 1793 *
1743 * Remembers that this specific statistics value was received for this peer. 1794 * Remembers that this specific statistics value was received for this peer.
@@ -1801,10 +1852,14 @@ char* stat_type_2_str (enum STAT_TYPE stat_type)
1801 return "# rounds blocked"; 1852 return "# rounds blocked";
1802 case STAT_TYPE_BLOCKS_MANY_PUSH: 1853 case STAT_TYPE_BLOCKS_MANY_PUSH:
1803 return "# rounds blocked - too many pushes"; 1854 return "# rounds blocked - too many pushes";
1804 case STAT_TYPE_BLOCKS_FEW_PUSH: 1855 case STAT_TYPE_BLOCKS_NO_PUSH:
1805 return "# rounds blocked - no pushes"; 1856 return "# rounds blocked - no pushes";
1806 case STAT_TYPE_BLOCKS_FEW_PULL: 1857 case STAT_TYPE_BLOCKS_NO_PULL:
1807 return "# rounds blocked - no pull replies"; 1858 return "# rounds blocked - no pull replies";
1859 case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
1860 return "# rounds blocked - too many pushes, no pull replies";
1861 case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
1862 return "# rounds blocked - no pushes, no pull replies";
1808 case STAT_TYPE_ISSUED_PUSH_SEND: 1863 case STAT_TYPE_ISSUED_PUSH_SEND:
1809 return "# push send issued"; 1864 return "# push send issued";
1810 case STAT_TYPE_ISSUED_PULL_REQ: 1865 case STAT_TYPE_ISSUED_PULL_REQ:
@@ -1848,9 +1903,15 @@ stat_iterator (void *cls,
1848 int is_persistent) 1903 int is_persistent)
1849{ 1904{
1850 const struct STATcls *stat_cls = (const struct STATcls *) cls; 1905 const struct STATcls *stat_cls = (const struct STATcls *) cls;
1906 const struct RPSPeer *rps_peer = (const struct RPSPeer *) stat_cls->rps_peer;
1851 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", 1907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
1852 stat_type_2_str (stat_cls->stat_type), 1908 //stat_type_2_str (stat_cls->stat_type),
1909 name,
1853 value); 1910 value);
1911 to_file (rps_peer->file_name_stats,
1912 "%s: %" PRIu64 "\n",
1913 name,
1914 value);
1854 return GNUNET_OK; 1915 return GNUNET_OK;
1855} 1916}
1856 1917
@@ -1876,6 +1937,7 @@ void post_profiler (struct RPSPeer *rps_peer)
1876 stat_cls = GNUNET_malloc (sizeof (struct STATcls)); 1937 stat_cls = GNUNET_malloc (sizeof (struct STATcls));
1877 stat_cls->rps_peer = rps_peer; 1938 stat_cls->rps_peer = rps_peer;
1878 stat_cls->stat_type = stat_type; 1939 stat_cls->stat_type = stat_type;
1940 store_stats_file_name (rps_peer);
1879 GNUNET_STATISTICS_get (rps_peer->stats_h, 1941 GNUNET_STATISTICS_get (rps_peer->stats_h,
1880 "rps", 1942 "rps",
1881 stat_type_2_str (stat_type), 1943 stat_type_2_str (stat_type),
@@ -2141,8 +2203,10 @@ main (int argc, char *argv[])
2141 cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS | 2203 cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS |
2142 STAT_TYPE_BLOCKS | 2204 STAT_TYPE_BLOCKS |
2143 STAT_TYPE_BLOCKS_MANY_PUSH | 2205 STAT_TYPE_BLOCKS_MANY_PUSH |
2144 STAT_TYPE_BLOCKS_FEW_PUSH | 2206 STAT_TYPE_BLOCKS_NO_PUSH |
2145 STAT_TYPE_BLOCKS_FEW_PULL | 2207 STAT_TYPE_BLOCKS_NO_PULL |
2208 STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL |
2209 STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL |
2146 STAT_TYPE_ISSUED_PUSH_SEND | 2210 STAT_TYPE_ISSUED_PUSH_SEND |
2147 STAT_TYPE_ISSUED_PULL_REQ | 2211 STAT_TYPE_ISSUED_PULL_REQ |
2148 STAT_TYPE_ISSUED_PULL_REP | 2212 STAT_TYPE_ISSUED_PULL_REP |