Roger Dingledine commited on 2010-02-24 07:04:43
Zeige 1 geänderte Dateien mit 36 Einfügungen und 38 Löschungen.
... | ... |
@@ -904,44 +904,42 @@ a little bit of bandwidth, then flip a coin. Thanks for volunteering! |
904 | 904 |
<h3><a class="anchor" href="#RelayMemory">Why is my Tor relay using so |
905 | 905 |
much memory?</a></h3> |
906 | 906 |
|
907 |
-<p>There are three reasons for this. |
|
908 |
-</p> |
|
909 |
- |
|
910 |
-<p>The first is that Tor uses threads, so many of the measurements (such |
|
911 |
-as the output of top or ps) are inaccurate: they add up all the library |
|
912 |
-memory used by each thread, so the total "virtual" memory size will be |
|
913 |
-much larger than the actual amount of ram Tor is using. So this isn't |
|
914 |
-actually a problem — looking at the "resident" memory size instead should |
|
915 |
-be much more accurate (unless you're swapping a lot). (Note that on <a |
|
916 |
-href="https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#RelayOS">OpenBSD, |
|
917 |
-NetBSD, and old FreeBSD</a>, Tor uses a separate process for each thread, |
|
918 |
-since threading is broken on these platforms, so in these cases it |
|
919 |
-actually <i>is</i> using this much memory!) |
|
920 |
-</p> |
|
921 |
- |
|
922 |
-<p>The second reason is that Tor relays really do use quite a bit of |
|
923 |
-memory. Each connection that you hold open has a pair of memory buffers |
|
924 |
-that it uses for reading and writing from the network, and when many |
|
925 |
-connections are active at once, these buffers might grow quite large. We |
|
926 |
-used to have them shrink again immediately once they weren't full, but we |
|
927 |
-found that was using too much CPU — so now they stick around for a short |
|
928 |
-amount of time in case we need to use them again soon after. It is not |
|
929 |
-unusual for a fast exit relay to use several hundred megabytes of memory |
|
930 |
-(i.e.: you need about 768 MB RAM for a 10 MBit connected dedicated exit |
|
931 |
-node on Linux with Tor 0.1.2.14). |
|
932 |
-</p> |
|
933 |
- |
|
934 |
-<p>The third reason is that we may have some bugs somewhere. They fall |
|
935 |
-into the categories of "things we keep around in memory that are big |
|
936 |
-and we should probably get rid of", and "actual memory leaks". We're |
|
937 |
-working on these, but we'd love some help. We believe the 0.1.1.x stable |
|
938 |
-release was pretty good about this, but 0.1.2.x and 0.2.0.x are so far |
|
939 |
-quite bad. Please help! |
|
940 |
-</p> |
|
941 |
- |
|
942 |
-<p>Many linux users have found that in the 0.2.0.x series, <tt>configure |
|
943 |
---enable-openbsd-malloc</tt> fixes many of the linux malloc fragmentation |
|
944 |
-bugs. |
|
907 |
+<p>If your Tor relay is using more memory than you'd like, here are some |
|
908 |
+tips for reducing its footprint: |
|
909 |
+</p> |
|
910 |
+ |
|
911 |
+<ol> |
|
912 |
+<li>If you're on Linux, you may be encountering memory fragmentation |
|
913 |
+bugs in glibc's malloc implementation. That is, when Tor releases memory |
|
914 |
+back to the system, the pieces of memory are fragmented so they're hard |
|
915 |
+to reuse. The Tor tarball ships with OpenBSD's malloc implementation, |
|
916 |
+which doesn't have as many fragmentation bugs (but the tradeoff is higher |
|
917 |
+CPU load). You can tell Tor to use this malloc implementation instead: |
|
918 |
+<tt>./configure --enable-openbsd-malloc</tt></li> |
|
919 |
+ |
|
920 |
+<li>If you're running a fast relay, meaning you have many TLS connections |
|
921 |
+open, you are probably losing a lot of memory to OpenSSL's internal |
|
922 |
+buffers (38KB+ per socket). We've patched OpenSSL to release unused buffer |
|
923 |
+memory more aggressively. If you update to OpenSSL 1.0.0-beta5, Tor's |
|
924 |
+build process will automatically recognize and use this feature.</li> |
|
925 |
+ |
|
926 |
+<li>If you're running on Solaris, OpenBSD, NetBSD, or |
|
927 |
+old FreeBSD, Tor is probably forking separate processes |
|
928 |
+rather than using threads. Consider switching to a <a |
|
929 |
+href="https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#RelayOS">better |
|
930 |
+operating system</a>.</li> |
|
931 |
+ |
|
932 |
+<li>If you still can't handle the memory load, consider reducing the |
|
933 |
+amount of bandwidth your relay advertises. Advertising less bandwidth |
|
934 |
+means you will attract fewer users, so your relay shouldn't grow |
|
935 |
+as large. See the <tt>MaxAdvertisedBandwidth</tt> option in the man |
|
936 |
+page.</li> |
|
937 |
+ |
|
938 |
+</ol> |
|
939 |
+ |
|
940 |
+<p> |
|
941 |
+All of this said, fast Tor relays do use a lot of ram. It is not unusual |
|
942 |
+for a fast exit relay to use 500-1000 MB of memory. |
|
945 | 943 |
</p> |
946 | 944 |
|
947 | 945 |
<hr /> |
948 | 946 |