From: Eric Wong Date: 2018-06-21T23:06:48+00:00 Subject: [ruby-core:87584] Re: [Ruby trunk Bug#14858] Introduce 2nd GC heap named Transient heap ko1@atdot.net wrote: > https://bugs.ruby-lang.org/issues/14858 Thanks, I can confirm a good result with this. However, 32k is too small to be worth using mmap on. And maybe mmap is unnecessary (and bad for portability). Using malloc, I seem to get a tiny improvement in space and time: ``` --- a/transient_heap.c +++ b/transient_heap.c @@ -237,10 +237,8 @@ static struct transient_heap_block * transient_heap_block_alloc(struct transient_heap* theap) { struct transient_heap_block *block; - block = mmap(NULL, TRANSIENT_HEAP_BLOCK_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (block == MAP_FAILED) rb_bug("transient_heap_block_alloc: err:%d\n", errno); + block = malloc(TRANSIENT_HEAP_BLOCK_SIZE); + if (!block) rb_bug("transient_heap_block_alloc: err:%d\n", errno); reset_block(block); @@ -501,12 +499,7 @@ transient_heap_reset(void) theap->total_objects -= block->info.objects; #if TRANSIENT_HEAP_INFINITE_BLOCK_MODE // debug mode - if (madvise(block, TRANSIENT_HEAP_BLOCK_SIZE, MADV_DONTNEED) != 0) { - rb_bug("madvise err:%d", errno); - } - if (mprotect(block, TRANSIENT_HEAP_BLOCK_SIZE, PROT_NONE) != 0) { - rb_bug("mprotect err:%d", errno); - } + free(block); theap->total_blocks--; #else reset_block(block); ``` Unsubscribe: