Skip to content

Commit 95a1a07

Browse files
committed
Less aggressive initial heap size
1 parent 1f55bed commit 95a1a07

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ jobs:
159159
FLAKE_REGRESSION_GLOB: ${{ matrix.glob }}
160160
NIX_CONFIG: ${{ matrix.nix_config }}
161161
PREFETCH: "1"
162-
#GC_INITIAL_HEAP_SIZE: "32G"
163162
run: |
164163
set -x
165164
echo "PARALLEL: $PARALLEL"

src/libexpr/eval-gc.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static inline void initGCReal()
9898
GC_set_oom_fn(oomHandler);
9999

100100
/* Set the initial heap size to something fairly big (80% of
101-
free RAM, up to a maximum of 8 GiB) so that in most cases
101+
free RAM, up to a maximum of 4 GiB) so that in most cases
102102
we don't need to garbage collect at all. (Collection has a
103103
fairly significant overhead.) The heap size can be overridden
104104
through libgc's GC_INITIAL_HEAP_SIZE environment variable. We
@@ -109,12 +109,10 @@ static inline void initGCReal()
109109
if (!getEnv("GC_INITIAL_HEAP_SIZE")) {
110110
size_t size = 32 * 1024 * 1024;
111111
# if HAVE_SYSCONF && defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
112-
size_t maxSize = 8ULL * 1024 * 1024 * 1024;
112+
size_t maxSize = 4ULL * 1024 * 1024 * 1024;
113113
auto free = getFreeMem();
114-
debug("free memory is %d bytes", free);
115-
size = std::min((size_t) (free * 0.8), maxSize);
114+
size = std::max(size, std::min((size_t) (free * 0.5), maxSize));
116115
# endif
117-
debug("setting initial heap size to %1% bytes", size);
118116
GC_expand_hp(size);
119117
}
120118
}

0 commit comments

Comments
 (0)