I have tor 0.3.1.9 running as non-exit relay.
From time to time it starts consuming 100% of CPU. Even though network traffic is minimal.
Is it normal? If not, how can I help you to investigate it?
My system is Win 7 x64 SP1, cpu is Core i5-3570.
Trac: Username: Eugene646
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
No, there is no pattern. It happens some days and may last from few minutes to few hours. Not necessarily at start. There is no reliable way of reproducing.
Maybe I could enable some debug logging or like that?
I'm also experiencing same issue. System is Win7 64-bit on Intel E6850, Tor version is 0.3.1.9, running as service, non-exit, non-bridge relay, although DirPort is enabled. From time to time Tor process start consuming 100% of both CPU cores, network activity during this spikes on both ORPort and DirPort is next to nothing (1-3 kbps). These spikes' pattern also does not depend on whenever I'm using relay myself. Moreover, task manager shows ~50% of kernel time of CPU utilization (some file/network operations maybe).
I have fragment of 'debug'-level logfile which is very big to post but I could do some parsing on it (like count repeating lines and comparing it to 'notice'-level log), I could also post torrc contents.
Or maybe I should create another ticket? Child ticket possibly?
I think I'm seeing this same bug, or at least something very similar.
I run Tor as a non-exit relay in an LXC container on a Gentoo Linux box on an Intel Core i7-6700K, with Tor constantly shuffling 10Mb/s of traffic. Some random time after starting the Tor service, it starts eating one entire CPU core.
I'm not sure if it's related, since I don't have CPU usage history for this container and thus don't know when the 100% CPU usage started, but the Tor log contains a lot of these messages:
Jan 24 05:17:24.000 [warn] Failing because we have 4063 connections already. Please read doc/TUNING for guidance. [over 16000001 similar message(s) suppressed in last 21600 seconds]
If that suppression count is correct, that's 740 messages per second, which seems a bit excessive.
I'm currently running this package:
net-vpn/tor-0.3.2.9::gentoo was built with the following:USE="-libressl -lzma -scrypt seccomp (-selinux) -systemd -test tor-hardening -web -zstd" ABI_X86="(64)"
The logs suggest the following timeline:
Dec 9: First occurrence of the "Failing because we have X connections already" message, X=29967, on a Tor 0.3.2.2-alpha with 55 days of uptime.
Dec 10: Next message, X=29967.
Dec 15: Tor upgraded to 0.3.2.6-alpha.
Dec 22: Next message, X=29967, at 6 days 6 hours uptime.
Dec 30: Next message, X=29967, at 15 days 6 hours uptime.
Jan 1: 2 messages, X=29967, with 6 hours interval.
Jan 2: 1 message, X=29967, 21 hours after the last one.
Jan 7: Machine is rebooted to kernel 4.14.11 to get initial Meltdown patches. Failure messages start coming 4 minutes after starting the service, with X=4063.
Jan 7-21: Failure messages come regularly every 6 hours, X=4063.
Jan 21: Tor is upgraded to 0.3.2.9. Failure messages start coming 7 minutes after starting the service, with X=4063.
Jan 21-24 (now): Failure messages come regularly every 6 hours, X=4063.
The Tor process uses 100% CPU (i.e. one core), but not very much memory - currently 900M virtual, 300M resident.
"perf top" on the Tor process isn't very helpful; at the top is perf's own BPF stuff at 5-10% CPU time, followed by pthread functions in glibc at ~2-3%. Actual Tor code is way down the list; the only function visible without going ridiculously low is "assert_connection_ok" at 1% CPU time.
"strace" on the Tor process sees mostly calls to epoll_pwait():
Actually, a whole lot of them; strace counts around 69000 such calls per second, with other syscalls during one random second coming in at much lower counts:
I restarted the Tor service and watched it closely. The error message "Failing because we have 4063 connections already" appears at the same time as it starts using 100% CPU. This time it took 6 minutes.
At 3 minutes after starting the service, well after the log says the relay is up and running, "perf top" looks nice and sane like this:
And says the Tor process is spending 65% of its time in the kernel. Probably with those 69k/s epoll_pwait() calls.
Network statistics says it's still shuffling its 10Mb/s, though, so it's doing something productive as well.
Final Tor log is not very interesting, but for completeness:
Jan 24 10:49:47.000 [notice] Tor 0.3.2.9 (git-9e8b762fcecfece6) opening log file.Jan 24 10:49:47.000 [notice] Parsing GEOIP IPv4 file /usr/share/tor/geoip.Jan 24 10:49:48.000 [notice] Parsing GEOIP IPv6 file /usr/share/tor/geoip6.Jan 24 10:49:48.000 [notice] Configured to measure statistics. Look for the *-stats files that will first be written to the data directory in 24 hours from now.Jan 24 10:49:48.000 [notice] Your Tor server's identity key fingerprint is CENSOREDJan 24 10:49:48.000 [notice] Bootstrapped 0%: StartingJan 24 10:49:54.000 [notice] Starting with guard context "default"Jan 24 10:49:54.000 [notice] Bootstrapped 80%: Connecting to the Tor networkJan 24 10:49:54.000 [notice] Self-testing indicates your ORPort is reachable from the outside. Excellent.Jan 24 10:49:54.000 [notice] Bootstrapped 85%: Finishing handshake with first hopJan 24 10:49:55.000 [notice] Bootstrapped 90%: Establishing a Tor circuitJan 24 10:49:56.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.Jan 24 10:49:56.000 [notice] Bootstrapped 100%: DoneJan 24 10:49:58.000 [notice] Self-testing indicates your DirPort is reachable from the outside. Excellent. Publishing server descriptor.Jan 24 10:50:00.000 [notice] Performing bandwidth self-test...done.Jan 24 10:56:04.000 [warn] Failing because we have 4063 connections already. Please read doc/TUNING for guidance.
Jan 24 05:17:24.000 [warn] Failing because we have 4063 connections already. Please read doc/TUNING for guidance. [over 16000001 similar message(s) suppressed in last 21600 seconds]
You need to give Tor access to more file descriptors. Tor relays need to be able to reach the other Tor relays, and 4096-or-so descriptors is not enough.
I see next log messages when tor service use 100% CPU
Feb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from BDCF9DAE9B06BE846F509A2CD4622D0296F4C524A5B97FD55B87A19082BFFD44 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from BDCF9DAE9B06BE846F509A2CD4622D0296F4C524A5B97FD55B87A19082BFFD44 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from A2C8550157121D20120939A0CE806E8C80F9EAD261EEF569840D433EC4AADA83 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from A2C8550157121D20120939A0CE806E8C80F9EAD261EEF569840D433EC4AADA83 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from 96CCFFE34D19FE0E9A271C171C9E29EE2D95A309CBCDA05071F65B9BDE0F05AC to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from 96CCFFE34D19FE0E9A271C171C9E29EE2D95A309CBCDA05071F65B9BDE0F05AC to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from 743550945E24E932FA2A4548160FB7B94A56E8DB36F0024BDBB0DA0B0C084CBB to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:54.000 [info] store_multiple(): Adding consensus diff from 743550945E24E932FA2A4548160FB7B94A56E8DB36F0024BDBB0DA0B0C084CBB to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from 6E83B5ED1443A63C1D2A227E40C14876CE9A444D31F2797EBEBD3131875F9804 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from 6E83B5ED1443A63C1D2A227E40C14876CE9A444D31F2797EBEBD3131875F9804 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from C1733C9DB3D3FFA41648B4512D3ED9088706828C0B46B63910F9334CD18D71B3 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from C1733C9DB3D3FFA41648B4512D3ED9088706828C0B46B63910F9334CD18D71B3 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from D21909A5CCEAE66D820DCB25D5BBF6591B8E4D7199FBE52C6F2B4D7607F445D6 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from D21909A5CCEAE66D820DCB25D5BBF6591B8E4D7199FBE52C6F2B4D7607F445D6 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from 244325664A3D3FEA6EEE708E3A7F5457B9313C108C744275A7A6BAB031E1783F to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from 244325664A3D3FEA6EEE708E3A7F5457B9313C108C744275A7A6BAB031E1783F to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from 8A68AF897614AB690785BF1C709249ADCDEA2E78657B41CE55285FAE3D3672CE to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:55.000 [info] store_multiple(): Adding consensus diff from 8A68AF897614AB690785BF1C709249ADCDEA2E78657B41CE55285FAE3D3672CE to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:56.000 [info] store_multiple(): Adding consensus diff from 1520D1CA72D0806C7F627C57ED9B1380904CFD24F504762A4B4649DF1B70CC4B to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:56.000 [info] store_multiple(): Adding consensus diff from 1520D1CA72D0806C7F627C57ED9B1380904CFD24F504762A4B4649DF1B70CC4B to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:56.000 [info] store_multiple(): Adding consensus diff from ACFCFDD29853CA1EB252867E1643F9B7A2C389DD2BC5B4F3FC44EBA8F2D772CC to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:56.000 [info] store_multiple(): Adding consensus diff from ACFCFDD29853CA1EB252867E1643F9B7A2C389DD2BC5B4F3FC44EBA8F2D772CC to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:57.000 [info] store_multiple(): Adding consensus diff from 09783C82602523E03D46483573F927E768EC2C70E1008956EEEFFA80185EC0AB to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:57.000 [info] store_multiple(): Adding consensus diff from 09783C82602523E03D46483573F927E768EC2C70E1008956EEEFFA80185EC0AB to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:57.000 [info] store_multiple(): Adding consensus diff from 39AE8F1436B0C78B5A39A90D46EB46A960E30253595DB9B6EC74E80B8532185D to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:57.000 [info] store_multiple(): Adding consensus diff from 39AE8F1436B0C78B5A39A90D46EB46A960E30253595DB9B6EC74E80B8532185D to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzipFeb 24 00:15:57.000 [info] store_multiple(): Adding consensus diff from 4E9D2911D8985DB0810B80DA38A353D7DC89B686CB312B7D8A2CCE8B1CDE5370 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with identityFeb 24 00:15:57.000 [info] store_multiple(): Adding consensus diff from 4E9D2911D8985DB0810B80DA38A353D7DC89B686CB312B7D8A2CCE8B1CDE5370 to C195F4A134922B69D8DCA02C1C9D92586102A99, compressed with gzip
It's a regression, started from 0.3.1.x, and it looks like a dumb mingw implementation of some function, used in consdiff. #24826 (moved) didn't fix it.
Trac: Version: Tor: 0.3.2.9 to Tor: 0.3.1.9 Milestone: Tor: 0.3.4.x-final to Tor: 0.3.3.x-final Keywords: N/Adeleted, regression, performance added
it looks like a dumb mingw implementation of some function
#ifdef _WIN32/* On Windows, unlink won't work on a file if the file is actively mmap()ed. * That forces us to be less aggressive about unlinking files, and causes other * changes throughout our logic. */#define MUST_UNMAP_TO_UNLINK#endif /* defined(_WIN32) */
#ifdef MUST_UNMAP_TO_UNLINK /* If we can't unlink the files that we're still using, then we need to * tell the storagedir backend to allow far more files than this consensus * cache actually wants, so that it can hold files which, from this cache's * perspective, have become useless. */#define VERY_LARGE_STORAGEDIR_LIMIT (1000*1000) storagedir_max_entries = VERY_LARGE_STORAGEDIR_LIMIT;#else /* !(defined(MUST_UNMAP_TO_UNLINK)) */ /* Otherwise, we can just tell the storagedir to use the same limits * as this cache. */ storagedir_max_entries = max_entries;#endif /* defined(MUST_UNMAP_TO_UNLINK) */
get_max_age_to_cache(void){ const int32_t DEFAULT_MAX_AGE_TO_CACHE = 8192; const int32_t MIN_MAX_AGE_TO_CACHE = 0; const int32_t MAX_MAX_AGE_TO_CACHE = 8192; const char MAX_AGE_TO_CACHE_NAME[] = "max-consensus-age-to-cache-for-diff"; const or_options_t *options = get_options(); if (options->MaxConsensusAgeForDiffs) { const int v = options->MaxConsensusAgeForDiffs; if (v >= MAX_MAX_AGE_TO_CACHE * 3600) return MAX_MAX_AGE_TO_CACHE; else return v; } /* The parameter is in hours, so we multiply */ return 3600 * networkstatus_get_param(NULL, MAX_AGE_TO_CACHE_NAME, DEFAULT_MAX_AGE_TO_CACHE, MIN_MAX_AGE_TO_CACHE, MAX_MAX_AGE_TO_CACHE);}