[tor-dev] gettimeofday() Syscall Issues

Yawning Angel yawning at schwanenlied.me
Fri Jan 2 12:45:46 UTC 2015


On Fri, 2 Jan 2015 23:18:16 +1100
teor <teor2345 at gmail.com> wrote:
> IPredator has complained that tor on Linux spends too much time
> calling time() when pushing 500Mbit/s, which is an issue for them
> under 3.x series kernels, but not kernel 2.6.
> 
> https://ipredator.se/guide/torserver#performance

I really don't understand this, unless my benchmark methodology is
overly naive. time() in a trivial benchmark takes roughly 3 ns per call.

Linux doesn't even do a real syscall for gettimeofday() due to vDSO...

> I just reviewed my profiling of an exit relay running chutney verify
> with 200MB of random data. This is on OS X 10.9.5 with tor
> 0.2.6.2-alpha-dev running the chutney basic-min network.
> 
> The three leaf functions that take the most time in the call graph
> are:
> * channel_timestamp_recv
> * channel_timestamp_active
> * time
> 
> Each of these functions takes around 16% of the execution time, the
> next nearest function is sha1_block_data_order_avx on 4%.
>
> While I understand that OS X, BSD, and Linux syscalls aren't
> necessarily identical, we now have results for the following
> platforms suggesting that calling time() too often has a performance
> impact:
> * Linux kernel 3.x
> * OpenBSD
> * OS X 10.9
> 
> My results suggest a maximum performance improvement of 15% on OS X
> if we reduced the calls to time() to a reasonable number per second.

I'm still skeptical, but hey, the code needs love in general.  Maybe
nickm/dgoulet have more insight into this than I do, and this would also
be a good opportunity to switch more things over to monotonic time.

Regards,

-- 
Yawning Angel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20150102/62aebe2c/attachment.sig>


More information about the tor-dev mailing list