summaryrefslogtreecommitdiff
path: root/src/or/channel.h
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.h
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.h')
-rw-r--r--src/or/channel.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/or/channel.h b/src/or/channel.h
index 0f685011a3..4b60b7a7d6 100644
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@ -88,10 +88,9 @@ struct channel_s {
* Used to decide what channels to pad, and when. */
channel_usage_info_t channel_usage;
- /** When should we send a cell for netflow padding, in absolute
- * milliseconds since monotime system start. 0 means no padding
- * is scheduled. */
- uint64_t next_padding_time_ms;
+ /** When should we send a cell for netflow padding? 0 means no padding is
+ * scheduled. */
+ monotime_coarse_t next_padding_time;
/** The callback pointer for the padding callbacks */
tor_timer_t *padding_timer;
@@ -158,7 +157,7 @@ struct channel_s {
time_t timestamp_active; /* Any activity */
/**
- * This is a high-resolution monotonic timestamp that marks when we
+ * This is a monotonic timestamp that marks when we
* believe the channel has actually sent or received data to/from
* the wire. Right now, it is used to determine when we should send
* a padding cell for channelpadding.
@@ -167,7 +166,7 @@ struct channel_s {
* accurately reflect actual network data transfer? Or might this be
* very wrong wrt when bytes actually go on the wire?
*/
- uint64_t timestamp_xfer_ms;
+ monotime_coarse_t timestamp_xfer;
/* Methods implemented by the lower layer */