[#117392] [Ruby master Feature#20405] Inline comments — "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>

Issue #20405 has been reported by nobu (Nobuyoshi Nakada).

11 messages 2024/04/01

[#117434] [Ruby master Bug#20409] Missing reporting some invalid breaks — "kddnewton (Kevin Newton) via ruby-core" <ruby-core@...>

Issue #20409 has been reported by kddnewton (Kevin Newton).

8 messages 2024/04/03

[#117458] [Ruby master Bug#20414] `Fiber#raise` should recurse to `resumed_fiber` rather than failing. — "ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>

Issue #20414 has been reported by ioquatix (Samuel Williams).

10 messages 2024/04/07

[#117469] [Ruby master Feature#20415] Precompute literal String hash code during compilation — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>

Issue #20415 has been reported by byroot (Jean Boussier).

10 messages 2024/04/09

[#117494] [Ruby master Bug#20421] String#index and String#byteindex don't clear `$~` when offset > size (or bytesize) — "andrykonchin (Andrew Konchin) via ruby-core" <ruby-core@...>

Issue #20421 has been reported by andrykonchin (Andrew Konchin).

7 messages 2024/04/11

[#117498] [Ruby master Feature#20425] Optimize forwarding callers and callees — "tenderlovemaking (Aaron Patterson) via ruby-core" <ruby-core@...>

Issue #20425 has been reported by tenderlovemaking (Aaron Patterson).

14 messages 2024/04/11

[#117531] [Ruby master Bug#20431] Ruby 3.3.0 build fail with make: *** [io_buffer.o] Error 1 — "shubham_yadav (Shubham Yadav) via ruby-core" <ruby-core@...>

SXNzdWUgIzIwNDMxIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHNodWJoYW1feWFkYXYgKFNodWJoYW0g

11 messages 2024/04/16

[#117564] [Ruby master Bug#20433] Hash.inspect for some hash returns syntax invalid representation — "tompng (tomoya ishida) via ruby-core" <ruby-core@...>

Issue #20433 has been reported by tompng (tomoya ishida).

15 messages 2024/04/17

[#117572] [Ruby master Misc#20435] DevMeeting-2024-06-13 — "mame (Yusuke Endoh) via ruby-core" <ruby-core@...>

Issue #20435 has been reported by mame (Yusuke Endoh).

12 messages 2024/04/17

[#117588] [Ruby master Misc#20436] DevMeeting at RubyKaigi 2024 — "ko1 (Koichi Sasada) via ruby-core" <ruby-core@...>

SXNzdWUgIzIwNDM2IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtvMSAoS29pY2hpIFNhc2FkYSkuDQoN

14 messages 2024/04/18

[#117624] [Ruby master Bug#20440] `super` from child class passing keyword arg as Hash if in a method with passthrough args called from base class — "ozydingo (Andrew Schwartz) via ruby-core" <ruby-core@...>

Issue #20440 has been reported by ozydingo (Andrew Schwartz).

7 messages 2024/04/20

[#117644] [Ruby master Feature#20443] Allow Major GC's to be disabled — "eightbitraptor (Matthew Valentine-House) via ruby-core" <ruby-core@...>

Issue #20443 has been reported by eightbitraptor (Matthew Valentine-House).

25 messages 2024/04/22

[#117646] [Ruby master Bug#20444] Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly — "esad (Esad Hajdarevic) via ruby-core" <ruby-core@...>

Issue #20444 has been reported by esad (Esad Hajdarevic).

9 messages 2024/04/22

[#117653] [Ruby master Bug#20446] OUtdated https://cache.ruby-lang.org/pub/ruby/index.txt — "vo.x (Vit Ondruch) via ruby-core" <ruby-core@...>

Issue #20446 has been reported by vo.x (Vit Ondruch).

7 messages 2024/04/23

[#117657] [Ruby master Bug#20447] Ruby 3.3.1 broken on i686 — "vo.x (Vit Ondruch) via ruby-core" <ruby-core@...>

SXNzdWUgIzIwNDQ3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHZvLnggKFZpdCBPbmRydWNoKS4NCg0K

15 messages 2024/04/23

[#117658] [Ruby master Feature#20448] Make coverage event hooking C API public — "ms-tob (Matt S) via ruby-core" <ruby-core@...>

Issue #20448 has been reported by ms-tob (Matt S).

9 messages 2024/04/23

[#117674] [Ruby master Bug#20450] Ruby 3.1.1 broken with bootsnap — "philippe.bs.noel@... (Philippe Noel) via ruby-core" <ruby-core@...>

Issue #20450 has been reported by [email protected] (Philippe Noel).

11 messages 2024/04/24

[#117684] [Ruby master Bug#20452] Ruby 3.3 on Alpine Linux results in a relatively shallow SystemStackError exception — "Earlopain (A S) via ruby-core" <ruby-core@...>

Issue #20452 has been reported by Earlopain (A S).

12 messages 2024/04/24

[#117711] [Ruby master Bug#20456] Hash can get stuck marked as iterating through process forking — "blowfishpro (Talia Wong) via ruby-core" <ruby-core@...>

Issue #20456 has been reported by blowfishpro (Talia Wong).

7 messages 2024/04/25

[ruby-core:117644] [Ruby master Feature#20443] Allow Major GC's to be disabled

From: "eightbitraptor (Matthew Valentine-House) via ruby-core" <ruby-core@...>
Date: 2024-04-22 16:02:27 UTC
List: ruby-core #117644
Issue #20443 has been reported by eightbitraptor (Matthew Valentine-House).

----------------------------------------
Feature #20443: Allow Major GC's to be disabled
https://bugs.ruby-lang.org/issues/20443

* Author: eightbitraptor (Matthew Valentine-House)
* Status: Open
----------------------------------------
[[Github PR #10598]](https://github.com/ruby/ruby/pull/10598)

## Background

Ruby's GC running during Rails requests can have negative impacts on currently
running requests, causing applications to have high tail-latency.

A technique to mitigate this high tail-latency is Out-of-band GC (OOBGC). This
is basically where the application is run with GC disabled, and then GC is
explicitly started after each request, or when no requests are in progress.

This can reduce the tail latency, but also introduces problems of its own. Long
GC pauses after each request reduce throughput. This is more pronounced on
threading servers like Puma because all the threads have to finish processing
user requests and be "paused" before OOBGC can be triggered.

This throughput decrease happens for a couple of reasons:

1. There are few heuristics available for users to determine when GC should run,
this means that in OOBGC scenarios, it's possible that major GC's are being run
more than necessary.  2. The lack of any GC during a request means that lots of
garbage objects have been created and not cleaned up, so the process is using
more memory than it should - requiring major GC's run as part of OOBGC to do
more work and therefore take more time.

This ticket attempts to address these issues by:

1. Provide `GC.disable_major` and its antonym `GC.enable_major` to disable and
enable only major GC 2. Provide `GC.needs_major?` as a basic heuristic allowing
users to tell when Ruby should run a Major GC.

These ideas were originally proposed by @ko1 and @byroot in [this rails
issue](https://github.com/rails/rails/issues/50449)

Disabling GC major's would still allow minor GC's to run during the request,
avoiding the ballooning memory usage caused by not running GC at all, and
reducing the time that a major takes when we do run it, because the nursery
objects have been cleaned up during the request already so there is less work
for a major GC to do.

This can be used in combination with `GC.needs_major?` to selectively run an
OOBGC only when necessary

## Implementation

This PR adds 3 new methods to the `GC` module

- `GC.disable_major` This prevents major GC's from running automatically. It
  does not restrict minors. When `objspace->rgengc.need_major_gc` is set and a
  GC is run, instead of running a major, new heap pages will be allocated and a
  minor run instead. `objspace->rgengc.need_major_gc` will remain set until a
  major is manually run. If a major is not manually run then the process will
  eventually run out of memory.
  
  When major GC's are disabled, object promotion is disabled. That is, no
  objects will increment their ages during a minor GC. This is to attempt to
  minimise heap growth during the period between major GC's, by restricting the
  number of old-gen objects that will remain unconsidered by the GC until the
  next major.
  
  When `GC.start` is run, then major GC's will be enabled, a GC triggered with
  the options passed to `GC.start`, and then `disable_major` will be set to the
  state it was in before `GC.start` was called.
  
- `GC.enable_major` This simply unsets the bit preventing major GC's. This will
  revert the GC to normal generational behaviour. Everything behaves as default
  again.

- `GC.needs_major?` This exposes the value of `objspace->rgengc.need_major_gc`
  to the user level API. This is already exposed in
  `GC.latest_gc_info[:need_major_by]` but I felt that a simpler interface would
  make this easier to use and result in more readable code. eg.
  
```ruby out_of_band do GC.start if GC.needs_major?  end ```

Because object aging is disabled when majors are disabled it is recommended to
use this in conjunction with `Process.warmup`, which will prepare the heap by
running a major GC, compacting the heap, and promoting every remaining object to
old-gen. This ensures that minor GC's are running over the smallets possible set
of young objects when `GC.disable_major` is true.

## Benchmarks

We ran some tests in production on Shopify's core monolith over a weekend and
found that:

**Mean time spent in GC, as well as p99.9 and p99.99 GC times are all
improved.** 

<img width="1000" alt="Screenshot 2024-04-22 at 16 41 49"
src="https://github.com/ruby/ruby/assets/31869/6cff5b11-2e21-40c1-bb84-d994e0e1798d">

**p99 GC time is slightly higher.** 

<img width="1000" alt="Screenshot 2024-04-22 at 16 44 55"
src="https://github.com/ruby/ruby/assets/31869/dc645cbe-9495-46f0-8485-24e790c42f32">

We're running far fewer OOBGC major GC's now that we have `GC.needs_major?` than
we were before, and we believe that this is contributing to a slightly increased
number of minor GC's. raising the p99 slightly.

**App response times are all improved**

We see a 9% reduction in average and p99 response times when compared against
standard GC (4% p99.9 and p99.99).

<img width="1000" alt="Screenshot 2024-04-22 at 16 55 53"
src="https://github.com/ruby/ruby/assets/31869/8a80c102-1564-4bc9-ba44-6e9a8b85f971">


This drops slightly to an 8% reduction in average and p99 response times when
compared against standard OOBGC (3.59 p99.9 and 4% p99.99)

<img width="1000" alt="Screenshot 2024-04-22 at 16 56 10"
src="https://github.com/ruby/ruby/assets/31869/1baef7ea-0155-4ff9-8ba4-a967b75749fe">







-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- [email protected]
 To unsubscribe send an email to [email protected]
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

In This Thread

Prev Next