summaryrefslogtreecommitdiff
path: root/src/or/channel.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-12-13 09:34:20 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-13 09:46:58 -0500
commit219c969d7bf858c4df5fc6ee9b0c472a525b6b2a (patch)
tree2b3aa9585fe033c4c2a9a074e8ad90f5d0bead05 /src/or/channel.c
parentdd6dec2665af9964d8f940c27f3f0815a649424a (diff)
downloadtor-219c969d7bf858c4df5fc6ee9b0c472a525b6b2a.tar.gz
tor-219c969d7bf858c4df5fc6ee9b0c472a525b6b2a.zip
Use monotime_coarse for transfer times and padding times
Using absolute_msec requires a 64-bit division operation every time we calculate it, which gets expensive on 32-bit architectures. Instead, just use the lazy "monotime_coarse_get()" operation, and don't convert to milliseconds until we absolutely must. In this case, it seemed fine to use a full monotime_coarse_t rather than a truncated "stamp" as we did to solve this problem for the timerstamps in buf_t and packed_cell_t: There are vastly more cells and buffer chunks than there are channels, and using 16 bytes per channel in the worst case is not a big deal. There are still more millisecond operations here than strictly necessary; let's see any divisions show up in profiles.
Diffstat (limited to 'src/or/channel.c')
-rw-r--r--src/or/channel.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/or/channel.c b/src/or/channel.c
index 7fa9768171..845fc3cb44 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -3241,12 +3241,12 @@ channel_timestamp_active(channel_t *chan)
time_t now = time(NULL);
tor_assert(chan);
- chan->timestamp_xfer_ms = monotime_coarse_absolute_msec();
+ monotime_coarse_get(&chan->timestamp_xfer);
chan->timestamp_active = now;
/* Clear any potential netflow padding timer. We're active */
- chan->next_padding_time_ms = 0;
+ monotime_coarse_zero(&chan->next_padding_time);
}
/**
@@ -3311,13 +3311,13 @@ channel_timestamp_recv(channel_t *chan)
{
time_t now = time(NULL);
tor_assert(chan);
- chan->timestamp_xfer_ms = monotime_coarse_absolute_msec();
+ monotime_coarse_get(&chan->timestamp_xfer);
chan->timestamp_active = now;
chan->timestamp_recv = now;
/* Clear any potential netflow padding timer. We're active */
- chan->next_padding_time_ms = 0;
+ monotime_coarse_zero(&chan->next_padding_time);
}
/**
@@ -3332,13 +3332,13 @@ channel_timestamp_xmit(channel_t *chan)
time_t now = time(NULL);
tor_assert(chan);
- chan->timestamp_xfer_ms = monotime_coarse_absolute_msec();
+ monotime_coarse_get(&chan->timestamp_xfer);
chan->timestamp_active = now;
chan->timestamp_xmit = now;
/* Clear any potential netflow padding timer. We're active */
- chan->next_padding_time_ms = 0;
+ monotime_coarse_zero(&chan->next_padding_time);
}
/***************************************************************