1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-08 13:10:19 +02:00

Don't release shared worklist buffers when less than 256 kB

Fixes https://github.com/wingo/whippet/issues/8.
This commit is contained in:
Andy Wingo 2024-09-16 10:51:07 +02:00
parent 7984f60eae
commit cf570d0206

View file

@ -29,6 +29,8 @@ struct shared_worklist_buf {
// Max size: 2 GB on 64-bit systems, 1 GB on 32-bit.
#define shared_worklist_buf_max_log_size ((unsigned) 28)
static const size_t shared_worklist_release_byte_threshold = 256 * 1024;
static int
shared_worklist_buf_init(struct shared_worklist_buf *buf, unsigned log_size) {
ASSERT(log_size >= shared_worklist_buf_min_log_size);
@ -59,8 +61,9 @@ shared_worklist_buf_byte_size(struct shared_worklist_buf *buf) {
static void
shared_worklist_buf_release(struct shared_worklist_buf *buf) {
if (buf->data)
madvise(buf->data, shared_worklist_buf_byte_size(buf), MADV_DONTNEED);
size_t byte_size = shared_worklist_buf_byte_size(buf);
if (buf->data && byte_size >= shared_worklist_release_byte_threshold)
madvise(buf->data, byte_size, MADV_DONTNEED);
}
static void