Commit db94b7f4 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Count bytes we spend on answering directory requests.

parent 863b6c43
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
  o Minor features:
    - Relays report the number of bytes spent on answering directory
      requests in extra-info descriptors similar to {read,write}-history.
      Implements enhancement 1790.
+11 −0
Original line number Diff line number Diff line
@@ -779,6 +779,17 @@
           had a smaller bandwidth than md, the other half had a larger
           bandwidth than md.

    "dirreq-read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM... NL
        [At most once]
    "dirreq-write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM... NL
        [At most once]

        Declare how much bandwidth the OR has spent on answering directory
        requests.  Usage is divided into intervals of NSEC seconds.  The
        YYYY-MM-DD HH:MM:SS field defines the end of the most recent
        interval.  The numbers are the number of bytes used in the most
        recent intervals, ordered from oldest to newest.

    "entry-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
        [At most once.]

+6 −0
Original line number Diff line number Diff line
@@ -440,6 +440,12 @@ static config_var_t _state_vars[] = {
  V(BWHistoryWriteEnds,               ISOTIME,  NULL),
  V(BWHistoryWriteInterval,           UINT,     "900"),
  V(BWHistoryWriteValues,             CSV,      ""),
  V(BWHistoryDirReadEnds,             ISOTIME,  NULL),
  V(BWHistoryDirReadInterval,         UINT,     "900"),
  V(BWHistoryDirReadValues,           CSV,      ""),
  V(BWHistoryDirWriteEnds,            ISOTIME,  NULL),
  V(BWHistoryDirWriteInterval,        UINT,     "900"),
  V(BWHistoryDirWriteValues,          CSV,      ""),

  V(TorVersion,                       STRING,   NULL),

+10 −2
Original line number Diff line number Diff line
@@ -2082,8 +2082,6 @@ static void
connection_buckets_decrement(connection_t *conn, time_t now,
                             size_t num_read, size_t num_written)
{
  if (!connection_is_rate_limited(conn))
    return; /* local IPs are free */
  if (num_written >= INT_MAX || num_read >= INT_MAX) {
    log_err(LD_BUG, "Value out of range. num_read=%lu, num_written=%lu, "
             "connection type=%s, state=%s",
@@ -2095,6 +2093,16 @@ connection_buckets_decrement(connection_t *conn, time_t now,
    tor_fragile_assert();
  }

  /* Count bytes of answering direct and tunneled directory requests */
  if (conn->type == CONN_TYPE_DIR && conn->purpose == DIR_PURPOSE_SERVER) {
    if (num_read > 0)
      rep_hist_note_dir_bytes_read(num_read, now);
    if (num_written > 0)
      rep_hist_note_dir_bytes_written(num_written, now);
  }

  if (!connection_is_rate_limited(conn))
    return; /* local IPs are free */
  if (num_read > 0) {
    if (conn->type == CONN_TYPE_EXIT)
      rep_hist_note_exit_bytes_read(conn->port, num_read);
+6 −0
Original line number Diff line number Diff line
@@ -2842,6 +2842,12 @@ typedef struct {
  time_t      BWHistoryWriteEnds;
  int         BWHistoryWriteInterval;
  smartlist_t *BWHistoryWriteValues;
  time_t      BWHistoryDirReadEnds;
  int         BWHistoryDirReadInterval;
  smartlist_t *BWHistoryDirReadValues;
  time_t      BWHistoryDirWriteEnds;
  int         BWHistoryDirWriteInterval;
  smartlist_t *BWHistoryDirWriteValues;

  /** Build time histogram */
  config_line_t * BuildtimeHistogram;
Loading