[#110568] [Ruby master Misc#19096] [Question] Time with `-00:00` offset is in UTC — "andrykonchin (Andrew Konchin)" <noreply@...>

SXNzdWUgIzE5MDk2IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGFuZHJ5a29uY2hpbiAoQW5kcmV3IEtv

10 messages 2022/11/01

[#110578] [Ruby master Feature#19099] Support `private_constant` for an undefined constant — "ujihisa (Tatsuhiro Ujihisa)" <noreply@...>

SXNzdWUgIzE5MDk5IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHVqaWhpc2EgKFRhdHN1aGlybyBVamlo

7 messages 2022/11/02

[#110621] [Ruby master Feature#19104] Introduce the cache-based optimization for Regexp matching — "make_now_just (Kitsune TSUYUSATO)" <noreply@...>

SXNzdWUgIzE5MTA0IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IG1ha2Vfbm93X2p1c3QgKEtpdHN1bmUg

8 messages 2022/11/05

[#110636] [Ruby master Bug#19108] Format routines like pack blindly treat a string as ASCII-encoded — "chrisseaton (Chris Seaton)" <noreply@...>

SXNzdWUgIzE5MTA4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGNocmlzc2VhdG9uIChDaHJpcyBTZWF0

8 messages 2022/11/07

[#110663] [Ruby master Bug#19113] Inconsistency in retention of compare_by_identity flag in Hash methods — "jeremyevans0 (Jeremy Evans)" <noreply@...>

SXNzdWUgIzE5MTEzIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGplcmVteWV2YW5zMCAoSmVyZW15IEV2

10 messages 2022/11/09

[#110670] [Ruby master Bug#19115] OpenSSL fails to autoload (macOS) — "thomthom (Thomas Thomassen)" <noreply@...>

SXNzdWUgIzE5MTE1IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHRob210aG9tIChUaG9tYXMgVGhvbWFz

10 messages 2022/11/09

[#110683] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name — "byroot (Jean Boussier)" <noreply@...>

SXNzdWUgIzE5MTE3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGJ5cm9vdCAoSmVhbiBCb3Vzc2llciku

53 messages 2022/11/10

[#110689] [Ruby master Bug#19119] Add an interface for out-of-process profiling tools to access Ruby information — "kjtsanaktsidis (KJ Tsanaktsidis)" <noreply@...>

SXNzdWUgIzE5MTE5IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtqdHNhbmFrdHNpZGlzIChLSiBUc2Fu

7 messages 2022/11/10

[#110708] [Ruby master Misc#19122] Use MADV_DONTNEED instead of MADV_FREE when freeing a Fiber's stack — "smcgivern (Sean McGivern)" <noreply@...>

SXNzdWUgIzE5MTIyIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHNtY2dpdmVybiAoU2VhbiBNY0dpdmVy

8 messages 2022/11/11

[#110737] [Ruby master Bug#19130] MRI failing when executing shell builtins with Errno::ENOENT — "ifiht (Mikal R)" <noreply@...>

SXNzdWUgIzE5MTMwIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGlmaWh0IChNaWthbCBSKS4NCg0KLS0t

9 messages 2022/11/14

[#110843] [Ruby master Feature#19141] Add thread-owned Monitor to protect thread-local resources — "wildmaples (Maple Ong)" <noreply@...>

SXNzdWUgIzE5MTQxIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHdpbGRtYXBsZXMgKE1hcGxlIE9uZyku

10 messages 2022/11/21

[#110870] [Ruby master Bug#19144] Ruby should set AI_V4MAPPED | AI_ADDRCONFIG getaddrinfo flags by default — "kjtsanaktsidis (KJ Tsanaktsidis)" <noreply@...>

SXNzdWUgIzE5MTQ0IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtqdHNhbmFrdHNpZGlzIChLSiBUc2Fu

7 messages 2022/11/24

[#110876] [Ruby master Bug#19147] `TestFileExhaustive#test_expand_path_for_existent_username` and `TestDir#test_home` fails on i686 — "vo.x (Vit Ondruch)" <noreply@...>

SXNzdWUgIzE5MTQ3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHZvLnggKFZpdCBPbmRydWNoKS4KCi0t

6 messages 2022/11/24

[#111027] [Ruby master Bug#19154] Specify require and autoload guarantees in ractors — "fxn (Xavier Noria)" <noreply@...>

Issue #19154 has been reported by fxn (Xavier Noria).

14 messages 2022/11/26

[#111036] [Ruby master Bug#19156] ObjectSpace.dump_all segfault during string inspection — mk <noreply@...>

Issue #19156 has been reported by mk (Matthias K=E4ppler).

25 messages 2022/11/28

[#111053] [Ruby master Bug#19158] Ruby 3.1.3 installs wrong gemspec for debug gem — deivid <noreply@...>

Issue #19158 has been reported by deivid (David Rodr=EDguez).

10 messages 2022/11/29

[#111075] [Ruby master Bug#19161] Cannot compile 3.0.5 or 3.1.3 on Red Hat 7 — "werebus (Matt Moretti)" <noreply@...>

SXNzdWUgIzE5MTYxIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHdlcmVidXMgKE1hdHQgTW9yZXR0aSku

15 messages 2022/11/29

[ruby-core:111007] [Ruby master Misc#19122] Use MADV_DONTNEED instead of MADV_FREE when freeing a Fiber's stack

From: "smcgivern (Sean McGivern)" <noreply@...>
Date: 2022-11-25 10:06:01 UTC
List: ruby-core #111007
Issue #19122 has been updated by smcgivern (Sean McGivern).


ioquatix (Samuel Williams) wrote in #note-2:
> I don't have a strong opinion about this, but I'm generally against loosing performance.
> 
> Maybe it can be controlled using environment variable.

Having this user-controllable works for me, although I don't know about the Ruby project's general stance on toggles like this.

@ioquatix is https://github.com/socketry/falcon-benchmark the right test suite to run here? I'm not sure if that's what you ran in https://bugs.ruby-lang.org/issues/15997#note-19, or if that was slightly different.

I'm happy to try this out with the various options here to quantify the current state - just point me in the right direction :-)

----------------------------------------
Misc #19122: Use MADV_DONTNEED instead of MADV_FREE when freeing a Fiber's stack
https://bugs.ruby-lang.org/issues/19122#change-100257

* Author: smcgivern (Sean McGivern)
* Status: Open
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
----------------------------------------
I'd like to propose that Ruby stops using MADV_FREE when freeing a Fiber's stack, and switches to using MADV_DONTNEED even when MADV_FREE is supported.

MADV_FREE is used in one place in the Ruby codebase, when freeing the stack of a freed Fiber: https://git.ruby-lang.org/ruby.git/tree/cont.c#n683

The comment for `fiber_pool_stack_free` says:

```c
// We advise the operating system that the stack memory pages are no longer being used.
// This introduce some performance overhead but allows system to relaim memory when there is pressure.
```

Where possible (i.e. on Linux 4.5 and later), `fiber_pool_stack_free` uses `MADV_FREE` over `MADV_DONTNEED`. This has the side effect that memory statistics such as RSS will not reduce until and unless the OS actually reclaims that memory. If that doesn't happen, then the reported memory usage via RSS will be much higher than the 'real' memory usage.

If this was pervasive throughtout the Ruby codebase then that would be one thing, but currently this is just for Fiber. This means that:

1. A program that doesn't use Fiber will have somewhat reliable RSS statistics on recent Linux.
2. A program that heavily uses Fiber (such as something using Async::HTTP) will see an inflated RSS statistic.

Go made a similar change to the one I'm proposing here for similar reasons: https://github.com/golang/go/issues/42330

> While `MADV_FREE` is somewhat faster than `MADV_DONTNEED`, it doesn't affect many of the statistics that `MADV_DONTNEED` does until the memory is actually reclaimed. This generally leads to poor user experience, like confusing stats in `top` and other monitoring tools; and bad integration with management systems that respond to memory usage.
> [...]
> I propose we change the default to prefer `MADV_DONTNEED` over `MADV_FREE`, to favor user-friendliness and minimal surprise over performance. I think it's become clear that Linux's implementation of `MADV_FREE` ultimately doesn't meet our needs.

As an aside, MADV_FREE was not used in Ruby 3.1 (https://bugs.ruby-lang.org/issues/19101), and I haven't found any bugs filed about this behaviour other than that one.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread