diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-11-21 12:28:16 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-11-27 09:43:15 -0500 |
commit | c3c0a05f51eff73e624b18f651339ed08a122e3d (patch) | |
tree | f679e50de45db6c6a5218bdb0815da4f5f058172 /src/common/buffers.c | |
parent | da82e0b5795c449f4442c87e065e9a60da4892a8 (diff) | |
download | tor-c3c0a05f51eff73e624b18f651339ed08a122e3d.tar.gz tor-c3c0a05f51eff73e624b18f651339ed08a122e3d.zip |
Add a new notion of "stamps" to be a fast 32-bit monotonic timestamp
The goal here is to replace our use of msec-based timestamps with
something less precise, but easier to calculate. We're doing this
because calculating lots of msec-based timestamps requires lots of
64/32 division operations, which can be inefficient on 32-bit
platforms.
We make sure that these stamps can be calculated using only the
coarse monotonic timer and 32-bit bitwise operations.
Diffstat (limited to 'src/common/buffers.c')
-rw-r--r-- | src/common/buffers.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common/buffers.c b/src/common/buffers.c index c45e13d551..e0ef0dc773 100644 --- a/src/common/buffers.c +++ b/src/common/buffers.c @@ -472,7 +472,7 @@ buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped) chunk = chunk_new_with_alloc_size(buf_preferred_chunk_size(capacity)); } - chunk->inserted_time = (uint32_t)monotime_coarse_absolute_msec(); + chunk->inserted_time = monotime_coarse_get_stamp(); if (buf->tail) { tor_assert(buf->head); @@ -487,8 +487,8 @@ buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped) } /** Return the age of the oldest chunk in the buffer <b>buf</b>, in - * milliseconds. Requires the current monotonic time, in truncated msec, - * as its input <b>now</b>. + * timestamp units. Requires the current monotonic timestamp as its + * input <b>now</b>. */ uint32_t buf_get_oldest_chunk_timestamp(const buf_t *buf, uint32_t now) |