public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114557] ehcleanup cleanup_empty_eh_merge_phis eats a lot of memory Date: Tue, 02 Apr 2024 09:56:02 +0000 [thread overview] Message-ID: <bug-114557-4-M5QtXID76H@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-114557-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114557 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2024-04-02 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The main reason is that the "large" PHI nodes are never re-used for large allocations and that the GTY ((deletable (""))) for the free_phinodes array doesn't seem to be effective for this testcase. diff --git a/gcc/tree-phinodes.cc b/gcc/tree-phinodes.cc index ddd731323e1..44dc345a3b7 100644 --- a/gcc/tree-phinodes.cc +++ b/gcc/tree-phinodes.cc @@ -223,6 +223,12 @@ release_phi_node (gimple *phi) delink_imm_use (imm); } + if (len - 2 >= NUM_BUCKETS - 2) + { + ggc_free (phi); + return; + } + bucket = len > NUM_BUCKETS - 1 ? NUM_BUCKETS - 1 : len; bucket -= 2; vec_safe_push (free_phinodes[bucket], phi); cuts memory usage to 10GB. The free_phinodes buckets are also badly designed - we always allocate power-of-two overall PHI node memory through ideal_phi_node_len but have buckets for [2, ..., 10] actual PHI nodes which likely makes us have exactly a single (maybe two) free PHI node buckets ... After ehcleanup (and with the above patch) we have (gdb) p/r free_phinodes $5 = {0x0, 0x0, 0x7ffff668e000, 0x0, 0x0, 0x0, 0x0, 0x7ffe8b3df000} so as I said. Two slots are used only. (gdb) p/r (free_phinodes)[2].m_vecpfx $7 = {m_alloc = 524287, m_using_auto_storage = 0, m_num = 265598} (gdb) p/r (free_phinodes)[7].m_vecpfx $8 = {m_alloc = 65535, m_using_auto_storage = 0, m_num = 59610} After the next collection the array is actually empty: (gdb) p/r free_phinodes $9 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} but memory usage doesn't shrink, likely either due to fragmentation or due to stale references. Maybe the 'deleteable' only gets effective upon next collection but we do not collect anymore after hitting 10GB, likely because we no longer expand the heap (hitting this peak is the bug anyway). We do re-collect in final(), but that doesn't reduce the memory. We do have a lot of blocks and edges and thus PHIs.
next prev parent reply other threads:[~2024-04-02 9:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-02 8:59 [Bug tree-optimization/114557] New: " rguenth at gcc dot gnu.org 2024-04-02 9:56 ` rguenth at gcc dot gnu.org [this message] 2024-04-02 10:30 ` [Bug tree-optimization/114557] " rguenth at gcc dot gnu.org 2024-04-03 6:57 ` cvs-commit at gcc dot gnu.org
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=bug-114557-4-M5QtXID76H@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).