Project

General

Profile

Actions

Feature #19785

closed

Deprecate `RUBY_GC_HEAP_INIT_SLOTS`

Added by peterzhu2118 (Peter Zhu) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114290]

Description

GitHub PR: https://github.com/ruby/ruby/pull/8147

The RUBY_GC_HEAP_INIT_SLOTS environment variable is replaced by
RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS (introduced in commit
3ab3455),
which allows for more fine-grained tuning of size pools. So it doesn't make
sense to keep the environment variable RUBY_GC_HEAP_INIT_SLOTS.

I'm proposing to deprecate RUBY_GC_HEAP_INIT_SLOTS and eventually remove it.

Actions #1

Updated by peterzhu2118 (Peter Zhu) over 1 year ago

  • Subject changed from Deprecate `RUBY_GC_HEAP_INIT_SLOTS ` to Deprecate `RUBY_GC_HEAP_INIT_SLOTS`
Actions #2

Updated by peterzhu2118 (Peter Zhu) over 1 year ago

  • Description updated (diff)

Updated by ko1 (Koichi Sasada) over 1 year ago

Sorry I didn't know about RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS

  • How to know %d part?
  • How to tune the value?
    • it seems difficult to set it compare with setting 1 init value.

Another idea is to introduce RUBY_GC_HEAP_INIT_PAGES for the global page pool. But I'm not sure there is global page pool yet. and not sure it will help for tuning.

Updated by peterzhu2118 (Peter Zhu) over 1 year ago

How to know %d part?

The %d part is the sizes returned from GC.stat_heap. On 64-bit systems, it's 40, 80, 160, 320, 640. On 32-bit systems it's 20, 40, 80, 160, 320.

How to tune the value?

You use RUBY_GC_HEAP_INIT_SIZE_40_SLOTS=4000000 to have 4M slots in the 40 byte size pool, for example.

it seems difficult to set it compare with setting 1 init value.

Yes, it is more difficult than setting one value, but users of this API should be aware of how the GC internals work if they want to use this.

Another idea is to introduce RUBY_GC_HEAP_INIT_PAGES for the global page pool.

The idea of RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS is to set initial sizes for Rails apps so the GC doesn't need to warm up. RUBY_GC_HEAP_INIT_PAGES will allocate pages to size pools based on the distribution of objects at boot, and I worry that it will be a different distribution than serving requests.

Updated by byroot (Jean Boussier) over 1 year ago

RUBY_GC_HEAP_INIT_PAGES will allocate pages to size pools based on the distribution of objects at boot, and I worry that it will be a different distribution than serving requests.

Unless the GC become capable of reusing an empty page of one pool for another? Assuming you call GC.compact or Process.warmup at the end of boot, the difference becomes marginal, and a single value becomes indeed much simpler to configure and keep up to date.

But perhaps I'm missing something?

Actions #6

Updated by peterzhu2118 (Peter Zhu) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|9ea9f992487711fa1a66637edcaf1327d0cd5099.


[Feature #19785] Deprecate RUBY_GC_HEAP_INIT_SLOTS

This environment variable is replaced by
RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS, so it doesn't make sense to keep it.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0