diff options
author | Julius Bünger <buenger@mytum.de> | 2018-01-22 04:32:33 +0100 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-01-22 04:32:33 +0100 |
commit | 8a9db739bafc7ab8fc533a19072649161daa5ef0 (patch) | |
tree | 129401d16d6a4506df7e83140d5f28d6aae95db2 /src/rps/test_rps.c | |
parent | 560cb250f65ca483535ac7d36e307bdf0261d1b5 (diff) | |
download | gnunet-8a9db739bafc7ab8fc533a19072649161daa5ef0.tar.gz gnunet-8a9db739bafc7ab8fc533a19072649161daa5ef0.zip |
rps profiler: more statistics from service
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 233 |
1 files changed, 207 insertions, 26 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index c958194a8..c5a2c0458 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -41,11 +41,6 @@ | |||
41 | static uint32_t num_peers; | 41 | static uint32_t num_peers; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * How many peers are ready to shutdown? | ||
45 | */ | ||
46 | static uint32_t num_shutdown_ready; | ||
47 | |||
48 | /** | ||
49 | * How long do we run the test? | 44 | * How long do we run the test? |
50 | */ | 45 | */ |
51 | //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 46 | //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
@@ -251,6 +246,38 @@ struct RPSPeer | |||
251 | * Handle to the statistics service | 246 | * Handle to the statistics service |
252 | */ | 247 | */ |
253 | struct GNUNET_STATISTICS_Handle *stats_h; | 248 | struct GNUNET_STATISTICS_Handle *stats_h; |
249 | |||
250 | /** | ||
251 | * @brief flags to indicate which statistics values have been already | ||
252 | * collected from the statistics service. | ||
253 | * Used to check whether we are able to shutdown. | ||
254 | */ | ||
255 | uint32_t stat_collected_flags; | ||
256 | }; | ||
257 | |||
258 | enum STAT_TYPE | ||
259 | { | ||
260 | STAT_TYPE_ROUNDS = 0x1, /* 1 */ | ||
261 | STAT_TYPE_BLOCKS = 0x2, /* 2 */ | ||
262 | STAT_TYPE_BLOCKS_MANY_PUSH = 0x4, /* 3 */ | ||
263 | STAT_TYPE_BLOCKS_FEW_PUSH = 0x8, /* 4 */ | ||
264 | STAT_TYPE_BLOCKS_FEW_PULL = 0x10, /* 5 */ | ||
265 | STAT_TYPE_ISSUED_PUSH_SEND = 0x20, /* 6 */ | ||
266 | STAT_TYPE_ISSUED_PULL_REQ = 0x40, /* 7 */ | ||
267 | STAT_TYPE_ISSUED_PULL_REP = 0x80, /* 8 */ | ||
268 | STAT_TYPE_SENT_PUSH_SEND = 0x100, /* 9 */ | ||
269 | STAT_TYPE_SENT_PULL_REQ = 0x200, /* 10 */ | ||
270 | STAT_TYPE_SENT_PULL_REP = 0x400, /* 11 */ | ||
271 | STAT_TYPE_RECV_PUSH_SEND = 0x800, /* 12 */ | ||
272 | STAT_TYPE_RECV_PULL_REQ = 0x1000, /* 13 */ | ||
273 | STAT_TYPE_RECV_PULL_REP = 0x2000, /* 14 */ | ||
274 | STAT_TYPE_MAX = 0x80000000, /* 32 */ | ||
275 | }; | ||
276 | |||
277 | struct STATcls | ||
278 | { | ||
279 | struct RPSPeer *rps_peer; | ||
280 | enum STAT_TYPE stat_type; | ||
254 | }; | 281 | }; |
255 | 282 | ||
256 | 283 | ||
@@ -333,7 +360,7 @@ typedef void (*ReplyHandle) (void *cls, | |||
333 | /** | 360 | /** |
334 | * Called directly before disconnecting from the service | 361 | * Called directly before disconnecting from the service |
335 | */ | 362 | */ |
336 | typedef void (*PostTest) (const struct RPSPeer *peer); | 363 | typedef void (*PostTest) (struct RPSPeer *peer); |
337 | 364 | ||
338 | /** | 365 | /** |
339 | * Function called after disconnect to evaluate test success | 366 | * Function called after disconnect to evaluate test success |
@@ -448,6 +475,12 @@ struct SingleTestRun | |||
448 | * Collect statistics at the end? | 475 | * Collect statistics at the end? |
449 | */ | 476 | */ |
450 | enum OPTION_COLLECT_STATISTICS have_collect_statistics; | 477 | enum OPTION_COLLECT_STATISTICS have_collect_statistics; |
478 | |||
479 | /** | ||
480 | * @brief Mark which values from the statistics service to collect at the end | ||
481 | * of the run | ||
482 | */ | ||
483 | uint32_t stat_collect_flags; | ||
451 | } cur_test_run; | 484 | } cur_test_run; |
452 | 485 | ||
453 | /** | 486 | /** |
@@ -594,6 +627,52 @@ make_oplist_entry () | |||
594 | 627 | ||
595 | 628 | ||
596 | /** | 629 | /** |
630 | * @brief Checks if given peer already received its statistics value from the | ||
631 | * statistics service. | ||
632 | * | ||
633 | * @param rps_peer the peer to check for | ||
634 | * | ||
635 | * @return #GNUNET_YES if so | ||
636 | * #GNUNET_NO otherwise | ||
637 | */ | ||
638 | static int check_statistics_collect_completed_single_peer ( | ||
639 | const struct RPSPeer *rps_peer) | ||
640 | { | ||
641 | if (cur_test_run.stat_collect_flags != | ||
642 | (cur_test_run.stat_collect_flags & | ||
643 | rps_peer->stat_collected_flags)) | ||
644 | { | ||
645 | return GNUNET_NO; | ||
646 | } | ||
647 | return GNUNET_YES; | ||
648 | } | ||
649 | /** | ||
650 | * @brief Checks if all peers already received their statistics value from the | ||
651 | * statistics service. | ||
652 | * | ||
653 | * @return #GNUNET_YES if so | ||
654 | * #GNUNET_NO otherwise | ||
655 | */ | ||
656 | static int check_statistics_collect_completed () | ||
657 | { | ||
658 | uint32_t i; | ||
659 | |||
660 | for (i = 0; i < num_peers; i++) | ||
661 | { | ||
662 | if (GNUNET_NO == check_statistics_collect_completed_single_peer (&rps_peers[i])) | ||
663 | { | ||
664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
665 | "At least Peer %" PRIu32 " did not yet receive all statistics values\n", | ||
666 | i); | ||
667 | return GNUNET_NO; | ||
668 | } | ||
669 | } | ||
670 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
671 | "All peers received their statistics values\n"); | ||
672 | return GNUNET_YES; | ||
673 | } | ||
674 | |||
675 | /** | ||
597 | * Task run on timeout to shut everything down. | 676 | * Task run on timeout to shut everything down. |
598 | */ | 677 | */ |
599 | static void | 678 | static void |
@@ -621,7 +700,7 @@ shutdown_op (void *cls) | |||
621 | } | 700 | } |
622 | /* If we do not collect statistics, shut down directly */ | 701 | /* If we do not collect statistics, shut down directly */ |
623 | if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics || | 702 | if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics || |
624 | num_peers <= num_shutdown_ready) | 703 | GNUNET_YES == check_statistics_collect_completed()) |
625 | { | 704 | { |
626 | GNUNET_SCHEDULER_shutdown (); | 705 | GNUNET_SCHEDULER_shutdown (); |
627 | } | 706 | } |
@@ -1661,6 +1740,7 @@ profiler_eval (void) | |||
1661 | /** | 1740 | /** |
1662 | * Continuation called by #GNUNET_STATISTICS_get() functions. | 1741 | * Continuation called by #GNUNET_STATISTICS_get() functions. |
1663 | * | 1742 | * |
1743 | * Remembers that this specific statistics value was received for this peer. | ||
1664 | * Checks whether all peers received their statistics yet. | 1744 | * Checks whether all peers received their statistics yet. |
1665 | * Issues the shutdown. | 1745 | * Issues the shutdown. |
1666 | * | 1746 | * |
@@ -1672,19 +1752,81 @@ void | |||
1672 | post_test_shutdown_ready_cb (void *cls, | 1752 | post_test_shutdown_ready_cb (void *cls, |
1673 | int success) | 1753 | int success) |
1674 | { | 1754 | { |
1675 | const struct RPSPeer *rps_peer = (const struct RPSPeer *) cls; | 1755 | struct STATcls *stat_cls = (struct STATcls *) cls; |
1676 | if (NULL != rps_peer->stat_op) | 1756 | struct RPSPeer *rps_peer = stat_cls->rps_peer; |
1757 | if (GNUNET_OK == success) | ||
1758 | { | ||
1759 | /* set flag that we we got the value */ | ||
1760 | rps_peer->stat_collected_flags |= stat_cls->stat_type; | ||
1761 | } else { | ||
1762 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1763 | "Peer %u did not receive statistics value\n", | ||
1764 | rps_peer->index); | ||
1765 | GNUNET_free (stat_cls); | ||
1766 | GNUNET_break (0); | ||
1767 | } | ||
1768 | |||
1769 | if (NULL != rps_peer->stat_op && | ||
1770 | GNUNET_YES == check_statistics_collect_completed_single_peer (rps_peer)) | ||
1677 | { | 1771 | { |
1678 | GNUNET_TESTBED_operation_done (rps_peer->stat_op); | 1772 | GNUNET_TESTBED_operation_done (rps_peer->stat_op); |
1679 | } | 1773 | } |
1680 | num_shutdown_ready++; | 1774 | |
1681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1775 | if (GNUNET_YES == check_statistics_collect_completed()) |
1682 | "%" PRIu32 " of %" PRIu32 " Peers are ready to shut down\n", | ||
1683 | num_shutdown_ready, | ||
1684 | num_peers); | ||
1685 | if (num_peers <= num_shutdown_ready) | ||
1686 | { | 1776 | { |
1777 | GNUNET_free (stat_cls); | ||
1778 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1779 | "Shutting down\n"); | ||
1687 | GNUNET_SCHEDULER_shutdown (); | 1780 | GNUNET_SCHEDULER_shutdown (); |
1781 | } else { | ||
1782 | GNUNET_free (stat_cls); | ||
1783 | } | ||
1784 | } | ||
1785 | |||
1786 | /** | ||
1787 | * @brief Converts #STAT_TYPE enum to the equivalent string representation that | ||
1788 | * is stored with the statistics service. | ||
1789 | * | ||
1790 | * @param stat_type #STAT_TYPE enum | ||
1791 | * | ||
1792 | * @return string representation that matches statistics value | ||
1793 | */ | ||
1794 | char* stat_type_2_str (enum STAT_TYPE stat_type) | ||
1795 | { | ||
1796 | switch (stat_type) | ||
1797 | { | ||
1798 | case STAT_TYPE_ROUNDS: | ||
1799 | return "# rounds"; | ||
1800 | case STAT_TYPE_BLOCKS: | ||
1801 | return "# rounds blocked"; | ||
1802 | case STAT_TYPE_BLOCKS_MANY_PUSH: | ||
1803 | return "# rounds blocked - too many pushes"; | ||
1804 | case STAT_TYPE_BLOCKS_FEW_PUSH: | ||
1805 | return "# rounds blocked - no pushes"; | ||
1806 | case STAT_TYPE_BLOCKS_FEW_PULL: | ||
1807 | return "# rounds blocked - no pull replies"; | ||
1808 | case STAT_TYPE_ISSUED_PUSH_SEND: | ||
1809 | return "# push send issued"; | ||
1810 | case STAT_TYPE_ISSUED_PULL_REQ: | ||
1811 | return "# pull request send issued"; | ||
1812 | case STAT_TYPE_ISSUED_PULL_REP: | ||
1813 | return "# pull reply send issued"; | ||
1814 | case STAT_TYPE_SENT_PUSH_SEND: | ||
1815 | return "# pushes sent"; | ||
1816 | case STAT_TYPE_SENT_PULL_REQ: | ||
1817 | return "# pull requests sent"; | ||
1818 | case STAT_TYPE_SENT_PULL_REP: | ||
1819 | return "# pull replys sent"; | ||
1820 | case STAT_TYPE_RECV_PUSH_SEND: | ||
1821 | return "# push message received"; | ||
1822 | case STAT_TYPE_RECV_PULL_REQ: | ||
1823 | return "# pull request message received"; | ||
1824 | case STAT_TYPE_RECV_PULL_REP: | ||
1825 | return "# pull reply messages received"; | ||
1826 | case STAT_TYPE_MAX: | ||
1827 | default: | ||
1828 | return "ERROR"; | ||
1829 | ; | ||
1688 | } | 1830 | } |
1689 | } | 1831 | } |
1690 | 1832 | ||
@@ -1705,21 +1847,46 @@ stat_iterator (void *cls, | |||
1705 | uint64_t value, | 1847 | uint64_t value, |
1706 | int is_persistent) | 1848 | int is_persistent) |
1707 | { | 1849 | { |
1708 | //const struct RPSPeer *rps_peer = (const struct RPSPeer *) cls; | 1850 | const struct STATcls *stat_cls = (const struct STATcls *) cls; |
1709 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %" PRIu64 "\n", value); | 1851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", |
1852 | stat_type_2_str (stat_cls->stat_type), | ||
1853 | value); | ||
1710 | return GNUNET_OK; | 1854 | return GNUNET_OK; |
1711 | } | 1855 | } |
1712 | 1856 | ||
1713 | void post_profiler (const struct RPSPeer *rps_peer) | 1857 | void post_profiler (struct RPSPeer *rps_peer) |
1714 | { | 1858 | { |
1715 | if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) | 1859 | if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) |
1716 | { | 1860 | { |
1717 | GNUNET_STATISTICS_get (rps_peer->stats_h, | 1861 | return; |
1718 | "rps", | 1862 | } |
1719 | "# rounds", | 1863 | |
1720 | post_test_shutdown_ready_cb, | 1864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1721 | stat_iterator, | 1865 | "Going to request statistic values with mask 0x%" PRIx32 "\n", |
1722 | (struct RPSPeer *) rps_peer); | 1866 | cur_test_run.stat_collect_flags); |
1867 | |||
1868 | struct STATcls *stat_cls; | ||
1869 | uint32_t stat_type; | ||
1870 | for (stat_type = STAT_TYPE_ROUNDS; | ||
1871 | stat_type < STAT_TYPE_MAX; | ||
1872 | stat_type = stat_type <<1) | ||
1873 | { | ||
1874 | if (stat_type & cur_test_run.stat_collect_flags) | ||
1875 | { | ||
1876 | stat_cls = GNUNET_malloc (sizeof (struct STATcls)); | ||
1877 | stat_cls->rps_peer = rps_peer; | ||
1878 | stat_cls->stat_type = stat_type; | ||
1879 | GNUNET_STATISTICS_get (rps_peer->stats_h, | ||
1880 | "rps", | ||
1881 | stat_type_2_str (stat_type), | ||
1882 | post_test_shutdown_ready_cb, | ||
1883 | stat_iterator, | ||
1884 | (struct STATcls *) stat_cls); | ||
1885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1886 | "Requested statistics for %s (peer %" PRIu32 ")\n", | ||
1887 | stat_type_2_str (stat_type), | ||
1888 | rps_peer->index); | ||
1889 | } | ||
1723 | } | 1890 | } |
1724 | } | 1891 | } |
1725 | 1892 | ||
@@ -1839,7 +2006,6 @@ main (int argc, char *argv[]) | |||
1839 | int ret_value; | 2006 | int ret_value; |
1840 | 2007 | ||
1841 | num_peers = 5; | 2008 | num_peers = 5; |
1842 | num_shutdown_ready = 0; | ||
1843 | cur_test_run.name = "test-rps-default"; | 2009 | cur_test_run.name = "test-rps-default"; |
1844 | cur_test_run.init_peer = default_init_peer; | 2010 | cur_test_run.init_peer = default_init_peer; |
1845 | cur_test_run.pre_test = NULL; | 2011 | cur_test_run.pre_test = NULL; |
@@ -1848,6 +2014,7 @@ main (int argc, char *argv[]) | |||
1848 | cur_test_run.post_test = NULL; | 2014 | cur_test_run.post_test = NULL; |
1849 | cur_test_run.have_churn = HAVE_CHURN; | 2015 | cur_test_run.have_churn = HAVE_CHURN; |
1850 | cur_test_run.have_collect_statistics = NO_COLLECT_STATISTICS; | 2016 | cur_test_run.have_collect_statistics = NO_COLLECT_STATISTICS; |
2017 | cur_test_run.stat_collect_flags = 0; | ||
1851 | churn_task = NULL; | 2018 | churn_task = NULL; |
1852 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); | 2019 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); |
1853 | 2020 | ||
@@ -1971,6 +2138,20 @@ main (int argc, char *argv[]) | |||
1971 | cur_test_run.have_churn = HAVE_CHURN; | 2138 | cur_test_run.have_churn = HAVE_CHURN; |
1972 | cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; | 2139 | cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; |
1973 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; | 2140 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; |
2141 | cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS | | ||
2142 | STAT_TYPE_BLOCKS | | ||
2143 | STAT_TYPE_BLOCKS_MANY_PUSH | | ||
2144 | STAT_TYPE_BLOCKS_FEW_PUSH | | ||
2145 | STAT_TYPE_BLOCKS_FEW_PULL | | ||
2146 | STAT_TYPE_ISSUED_PUSH_SEND | | ||
2147 | STAT_TYPE_ISSUED_PULL_REQ | | ||
2148 | STAT_TYPE_ISSUED_PULL_REP | | ||
2149 | STAT_TYPE_SENT_PUSH_SEND | | ||
2150 | STAT_TYPE_SENT_PULL_REQ | | ||
2151 | STAT_TYPE_SENT_PULL_REP | | ||
2152 | STAT_TYPE_RECV_PUSH_SEND | | ||
2153 | STAT_TYPE_RECV_PULL_REQ | | ||
2154 | STAT_TYPE_RECV_PULL_REP; | ||
1974 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300); | 2155 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300); |
1975 | 2156 | ||
1976 | /* 'Clean' directory */ | 2157 | /* 'Clean' directory */ |