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/91257] Compile-time and memory-hog hog Date: Mon, 04 Jan 2021 07:54:23 +0000 [thread overview] Message-ID: <bug-91257-4-atnQC4Qb9n@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-91257-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91257 --- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Rogério de Souza Moraes from comment #12) > Hi Richard, > > first, thank you for the great work improving the GCC performance. > > The R&D team which I am working with provided two test cases, they show that > it was possible to reduce the build time by taking out the block containing > setjmp/longjmp to a separate routine, which is only called from the original > routine. > > Both attached files, example_base.c and example_routines.c, are generated in > a very similar way, but in example_routines.c, all the 'try' macros are > taken out to separate routines. > > The compilation times: > example_base.c: > v4.8.3 - 0m1.096s > v6.3.0 - 0m16.017s > v9.3.0 - 0m26.829s > example_routines.c > v4.8.3 - 0m0.955s > v6.3.0 - 0m1.205s > v9.3.0 - 0m1.617s > > Is this approach ok to improve the build performance? Yes, that avoids the complex CFG. > Even if this approach is OK, there are still details unclear to us, and some > might be not even known: > > - Should we worry about inlining? Can we hint this to compiles, or should we > make sure it's avoided (by using routine pointers, for example)? In principle GCCs own heuristics should make sure it does not inline all of the single-use routines but for extra safety I'd suggest to use static void __attribute__((noinline)) routine_for_try_298(t__reg_s reg, int* v, int n0, int n1, int n2) { TRY_BEGIN { > - Can we assume that routine call (with all low-level work like copying data > on the stack etc.) is the only runtime performance price for this approach? I think so, yes (make sure to declare the functions static as above so the compiler can do IPA constant propagation, avoiding passing n0, n1, ..) > - Is having many small routines instead of a few very large is universally > good, or there are cases when it by itself can cause a problem? You are trading a complex callgraph for a complex CFG (though in the setjmp/longjmp case the CFG is artifically way more complex than the callgraph variant), so in general you trade intra-FN compile-time for inter-FN compile-time. So yes, there could be similar issues in GCCs IPA passes. But while it is possible to short-cut all IPA optimization there are select "transforms" on functions that do not scale well to arbitrary large functions / complex CFGs. A step further would decompose the TU with the many small functions into multiple TUs (if you'd use LTO for compiling then that's a no-op of course). > We appreciate very much any feedback. > > Best regards, > -- > Rogerio
next prev parent reply other threads:[~2021-01-04 7:54 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-91257-4@http.gcc.gnu.org/bugzilla/> 2020-12-11 17:36 ` rogerio.souza at gmail dot com 2020-12-11 17:38 ` rogerio.souza at gmail dot com 2020-12-11 17:40 ` rogerio.souza at gmail dot com 2021-01-04 7:54 ` rguenth at gcc dot gnu.org [this message] 2024-02-19 13:26 ` rguenth 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-91257-4-atnQC4Qb9n@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).