summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 1f8ff5e3ae..6b8885521a 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -4528,11 +4528,6 @@ compute_real_max_mem_in_queues(const uint64_t val, int log_guess)
if (val == 0) {
#define ONE_GIGABYTE (U64_LITERAL(1) << 30)
#define ONE_MEGABYTE (U64_LITERAL(1) << 20)
-#if SIZEOF_VOID_P >= 8
-#define MAX_DEFAULT_MAXMEM (8*ONE_GIGABYTE)
-#else
-#define MAX_DEFAULT_MAXMEM (2*ONE_GIGABYTE)
-#endif
/* The user didn't pick a memory limit. Choose a very large one
* that is still smaller than the system memory */
static int notice_sent = 0;
@@ -4547,14 +4542,30 @@ compute_real_max_mem_in_queues(const uint64_t val, int log_guess)
result = ONE_GIGABYTE;
#endif /* SIZEOF_VOID_P >= 8 */
} else {
- /* We detected it, so let's pick 3/4 of the total RAM as our limit. */
- const uint64_t avail = (ram / 4) * 3;
+ /* We detected the amount of memory available. */
+ uint64_t avail = 0;
+
+ if (ram >= (8 * ONE_GIGABYTE)) {
+ /* If we have 8 GB, or more, RAM available, we set the MaxMemInQueues
+ * to 0.4 * RAM. The idea behind this value is that the amount of RAM
+ * is more than enough for a single relay and should allow the relay
+ * operator to run two relays if they have additional bandwidth
+ * available.
+ */
+ avail = (ram / 5) * 2;
+ } else {
+ /* If we have less than 8 GB of RAM available, we use the "old" default
+ * for MaxMemInQueues of 0.75 * RAM.
+ */
+ avail = (ram / 4) * 3;
+ }
- /* Make sure it's in range from 0.25 GB to 8 GB. */
- if (avail > MAX_DEFAULT_MAXMEM) {
+ /* Make sure it's in range from 0.25 GB to 8 GB for 64-bit and 0.25 to 2
+ * GB for 32-bit. */
+ if (avail > MAX_DEFAULT_MEMORY_QUEUE_SIZE) {
/* If you want to use more than this much RAM, you need to configure
it yourself */
- result = MAX_DEFAULT_MAXMEM;
+ result = MAX_DEFAULT_MEMORY_QUEUE_SIZE;
} else if (avail < ONE_GIGABYTE / 4) {
result = ONE_GIGABYTE / 4;
} else {