[前][次][番号順一覧][スレッド一覧]

ruby-changes:74357

From: nagachika <ko1@a...>
Date: Sat, 5 Nov 2022 14:24:53 +0900 (JST)
Subject: [ruby-changes:74357] ad92236d24 (ruby_3_1): merge revision(s) 2bb89b7f114e4beb3012f63e12e726ae23005e6f: [Backport #19101]

https://git.ruby-lang.org/ruby.git/commit/?id=ad92236d24

From ad92236d245b791d14fd78bcb5a0a0789aa169c0 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sat, 5 Nov 2022 14:22:21 +0900
Subject: merge revision(s) 2bb89b7f114e4beb3012f63e12e726ae23005e6f: [Backport
 #19101]

	Lower priority of `POSIX_MADV_DONTNEED`. (#6671)

	---
	 cont.c | 21 ++++++++++++++++++---
	 1 file changed, 18 insertions(+), 3 deletions(-)
---
 cont.c    | 21 ++++++++++++++++++---
 version.h |  2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/cont.c b/cont.c
index 2d33ff4025..82b7e965b1 100644
--- a/cont.c
+++ b/cont.c
@@ -656,21 +656,36 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) https://github.com/ruby/ruby/blob/trunk/cont.c#L656
 
     if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"]\n", base, size, stack->base, stack->size);
 
-#if VM_CHECK_MODE > 0 && defined(MADV_DONTNEED)
+    // The pages being used by the stack can be returned back to the system.
+    // That doesn't change the page mapping, but it does allow the system to
+    // reclaim the physical memory.
+    // Since we no longer care about the data itself, we don't need to page
+    // out to disk, since that is costly. Not all systems support that, so
+    // we try our best to select the most efficient implementation.
+    // In addition, it's actually slightly desirable to not do anything here,
+    // but that results in higher memory usage.
+
+#ifdef __wasi__
+    // WebAssembly doesn't support madvise, so we just don't do anything.
+#elif VM_CHECK_MODE > 0 && defined(MADV_DONTNEED)
     // This immediately discards the pages and the memory is reset to zero.
     madvise(base, size, MADV_DONTNEED);
-#elif defined(POSIX_MADV_DONTNEED)
-    posix_madvise(base, size, POSIX_MADV_DONTNEED);
 #elif defined(MADV_FREE_REUSABLE)
+    // Darwin / macOS / iOS.
     // Acknowledge the kernel down to the task info api we make this
     // page reusable for future use.
     // As for MADV_FREE_REUSE below we ensure in the rare occasions the task was not
     // completed at the time of the call to re-iterate.
     while (madvise(base, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN);
 #elif defined(MADV_FREE)
+    // Recent Linux.
     madvise(base, size, MADV_FREE);
 #elif defined(MADV_DONTNEED)
+    // Old Linux.
     madvise(base, size, MADV_DONTNEED);
+#elif defined(POSIX_MADV_DONTNEED)
+    // Solaris?
+    posix_madvise(base, size, POSIX_MADV_DONTNEED);
 #elif defined(_WIN32)
     VirtualAlloc(base, size, MEM_RESET, PAGE_READWRITE);
     // Not available in all versions of Windows.
diff --git a/version.h b/version.h
index e70b3360d5..9ab52edcb0 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 3
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 175
+#define RUBY_PATCHLEVEL 176
 
 #define RUBY_RELEASE_YEAR 2022
 #define RUBY_RELEASE_MONTH 11
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]