From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jan Hubicka <hubicka@ucw.cz>
Subject: [PATCH 3/3] Use more ONE_? in GGC functions.
Date: Tue, 1 Sep 2020 14:33:04 +0200 [thread overview]
Message-ID: <11c9c279-e14f-3d68-95bc-2f2a0d9ed882@suse.cz> (raw)
In-Reply-To: <af188af5-5183-62e0-02ba-8d553644f321@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 78 bytes --]
The last patch is a refactoring using ONE_* macros.
Thoughts?
Thanks,
Martin
[-- Attachment #2: 0003-Use-more-ONE_-in-GGC-functions.patch --]
[-- Type: text/x-patch, Size: 3836 bytes --]
From 999a1969e7325efa0072d0ee893fcb6aa7178997 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 1 Sep 2020 14:24:20 +0200
Subject: [PATCH 3/3] Use more ONE_? in GGC functions.
gcc/ChangeLog:
* ggc-common.c (ggc_rlimit_bound): Use ONE_? macros.
(ggc_min_expand_heuristic): Likewise.
(ggc_min_heapsize_heuristic): Likewise.
* ggc-page.c (ggc_collect): Likewise.
* system.h (ONE_G): Likewise.
---
gcc/ggc-common.c | 16 ++++++++--------
gcc/ggc-page.c | 2 +-
gcc/system.h | 1 +
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index f6be5472bd5..a22f746e645 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -742,7 +742,7 @@ ggc_rlimit_bound (double limit)
appears to be ignored. Ignore such silliness. If a limit
this small was actually effective for mmap, GCC wouldn't even
start up. */
- && rlim.rlim_cur >= 8 * 1024 * 1024)
+ && rlim.rlim_cur >= 8 * ONE_M)
limit = rlim.rlim_cur;
# endif /* RLIMIT_AS or RLIMIT_DATA */
#endif /* HAVE_GETRLIMIT */
@@ -761,7 +761,7 @@ ggc_min_expand_heuristic (void)
/* The heuristic is a percentage equal to 30% + 70%*(RAM/1GB), yielding
a lower bound of 30% and an upper bound of 100% (when RAM >= 1GB). */
- min_expand /= 1024*1024*1024;
+ min_expand /= ONE_G;
min_expand *= 70;
min_expand = MIN (min_expand, 70);
min_expand += 30;
@@ -776,8 +776,8 @@ ggc_min_heapsize_heuristic (void)
double phys_kbytes = physmem_total ();
double limit_kbytes = ggc_rlimit_bound (phys_kbytes * 2);
- phys_kbytes /= 1024; /* Convert to Kbytes. */
- limit_kbytes /= 1024;
+ phys_kbytes /= ONE_K; /* Convert to Kbytes. */
+ limit_kbytes /= ONE_K;
/* The heuristic is RAM/8, with a lower bound of 4M and an upper
bound of 128M (when RAM >= 1GB). */
@@ -790,7 +790,7 @@ ggc_min_heapsize_heuristic (void)
struct rlimit rlim;
if (getrlimit (RLIMIT_RSS, &rlim) == 0
&& rlim.rlim_cur != (rlim_t) RLIM_INFINITY)
- phys_kbytes = MIN (phys_kbytes, rlim.rlim_cur / 1024);
+ phys_kbytes = MIN (phys_kbytes, rlim.rlim_cur / ONE_K);
}
# endif
@@ -798,12 +798,12 @@ ggc_min_heapsize_heuristic (void)
*next* GC would be within 20Mb of the limit or within a quarter of
the limit, whichever is larger. If GCC does hit the data limit,
compilation will fail, so this tries to be conservative. */
- limit_kbytes = MAX (0, limit_kbytes - MAX (limit_kbytes / 4, 20 * 1024));
+ limit_kbytes = MAX (0, limit_kbytes - MAX (limit_kbytes / 4, 20 * ONE_K));
limit_kbytes = (limit_kbytes * 100) / (110 + ggc_min_expand_heuristic ());
phys_kbytes = MIN (phys_kbytes, limit_kbytes);
- phys_kbytes = MAX (phys_kbytes, 4 * 1024);
- phys_kbytes = MIN (phys_kbytes, 128 * 1024);
+ phys_kbytes = MAX (phys_kbytes, 4 * ONE_K);
+ phys_kbytes = MIN (phys_kbytes, 128 * ONE_K);
return phys_kbytes;
}
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 0a43a7cdc0e..e5988ab1839 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -2184,7 +2184,7 @@ ggc_collect (void)
total allocations haven't expanded much since the last
collection. */
float allocated_last_gc =
- MAX (G.allocated_last_gc, (size_t)param_ggc_min_heapsize * 1024);
+ MAX (G.allocated_last_gc, (size_t)param_ggc_min_heapsize * ONE_K);
/* It is also good time to get memory block pool into limits. */
memory_block_pool::trim ();
diff --git a/gcc/system.h b/gcc/system.h
index 4f0482be25d..b0f3f1dd019 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1237,6 +1237,7 @@ void gcc_stablesort (void *, size_t, size_t,
#define ONE_K 1024
#define ONE_M (ONE_K * ONE_K)
+#define ONE_G (ONE_K * ONE_M)
/* Display a number as an integer multiple of either:
- 1024, if said integer is >= to 10 K (in base 2)
--
2.28.0
next prev parent reply other threads:[~2020-09-01 12:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 12:31 [PATCH 1/3] Support new mallinfo2 function Martin Liška
2020-09-01 12:32 ` [PATCH 2/3] Use MiB unit when displaying memory allocation Martin Liška
2020-09-01 14:04 ` Jan Hubicka
2020-09-02 13:28 ` Martin Liška
2020-09-17 21:57 ` Jeff Law
2020-09-22 7:47 ` Christophe Lyon
2020-09-22 8:30 ` Martin Liška
2020-09-22 13:02 ` Marek Polacek
2020-09-22 13:24 ` Marek Polacek
2020-09-01 12:33 ` Martin Liška [this message]
2020-09-02 13:29 ` [PATCH 3/3] Use more ONE_? in GGC functions Martin Liška
2020-09-17 21:57 ` Jeff Law
2020-09-01 13:38 ` [PATCH 4/N] Change timevar memory allocation to MiB Martin Liška
2020-09-02 13:29 ` Martin Liška
2020-09-02 13:28 ` [PATCH 1/3] Support new mallinfo2 function Martin Liška
2020-09-17 21:56 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11c9c279-e14f-3d68-95bc-2f2a0d9ed882@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).